regex delimiters issue
-
There seems to be an unnecessary requirement to use ‘/’ as regular expression delimiters. This is quite unfortunate as ‘/’ is likely to occur in the expression and have to be escaped (as illustrated in the examples). This is not a requirement of PHP.
/\/something\// would be simpler and less error-prone as (for example) %/something/%
In validate_regex(), replace:
if ( ! preg_match( '/^\/.*\/$/', $regex ) ) { $regex = '/' . $regex . '/'; }with
if ( substr($regex, 0, 1) !== substr($regex, -1) ) { $regex = '@' . $regex . '@'; }(untested example).
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘regex delimiters issue’ is closed to new replies.