isRegexp.php
Table of Contents
Functions
- isRegexp() : bool
- Determines whether a given string is a valid regular expression pattern.
Functions
isRegexp()
Determines whether a given string is a valid regular expression pattern.
isRegexp(string $pattern) : bool
This function checks if the string can be safely used in a preg_match() call.
It does not validate semantic correctness (e.g., useless patterns), only syntax.
⚠️ Internally uses the @ operator to suppress warnings from preg_match().
Parameters
- $pattern : string
-
The string to test as a potential regex pattern.
Tags
Return values
bool —true if the string is a valid PCRE regular expression, false otherwise.