PHP regular expressions: No ending delimiter ‘^’ found in

I’ve been having some trouble with regular expressions.

This is my code

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

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

I run it and get:

Warning: preg_match() [function.preg-match]: No ending delimiter ‘^’ found in


PHP regex strings need delimiters. Try:


Also, note that you have a lower case o, not a zero. In addition, if you’re just validating, you don’t need the capturing group, and can simplify the regex to /^\d+$/.


See also: PHP – Delimiters

Leave a Reply

Your email address will not be published. Required fields are marked *