php / php/php-src

Function to validate regular expression

Open
#9,289 14 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Extension: pcre Feature Status: Verified
Dominant language
C
Stars
40.4k
Forks
8.1k
Avg merge
2d 13h
Merged PRs (30d)
96

Description

Description

I have been missing a core function in PHP to validate a regular expression. I am therefore proposing something like preg_validate().

There are some workarounds mentioned in this StackOverflow thread. But from my understanding they will all produce a PHP warning that needs to be suppressed.
https://stackoverflow.com/questions/4440626/how-can-i-validate-regex

What are your thoughts and opinions on implementing a regex syntax validator?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the proposed preg_validate() entry point and the linked StackOverflow discussion about validating regex syntax. No source file or test is named, so first determine where a PHP core regex-validation function belongs and how warning suppression should be handled. Done requires an agreed implementation scope and tests for the proposed behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.