Problem
Regular expressions have been causing me some problems.
This is the code I use.
$pattern = "^([0-9]+)$";
if (preg_match($pattern, $input))
echo "yes";
else
echo "nope";
I run it and get the following results:
Asked by fingerman
Solution #1
Delimiters are required in PHP regex strings. Try:
$numpattern="/^([0-9]+)$/";
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+$/.
Example: http://ideone.com/Ec3zh
Also see PHP – Delimiters.
Answered by Kobi
Solution #2
Your regex pattern must be separated by delimiters:
$numpattern="/^([0-9]+)$/";
Answered by David Powers
Solution #3
You can use T-Regx, which does not require delimiters.
pattern('^([0-9]+)$')->match($input);
Answered by Danon
Post is based on https://stackoverflow.com/questions/4634993/php-regular-expressions-no-ending-delimiter-found-in