Coder Perfect

No ending delimiter ” detected in PHP regular expressions


Regular expressions have been causing me some problems.

This is the code I use.

$pattern = "^([0-9]+)$";

if (preg_match($pattern, $input))
   echo "yes";
   echo "nope";

I run it and get the following results:

Asked by fingerman

Solution #1

Delimiters are required in PHP regex strings. Try:


Also, instead of a zero, you have a lower case o. Furthermore, if you’re only verifying, the capturing group isn’t required, and the regex can be simplified to /d+$/.


Also see PHP – Delimiters.

Answered by Kobi

Solution #2

Your regex pattern must be separated by delimiters:


Answered by David Powers

Solution #3

You can use T-Regx, which does not require delimiters.


Answered by Danon

Post is based on