PHP Regular Expressions: No Ending Delimiter '^' Found In

PHP regular expressions: No ending delimiter '^' found in

PHP regex strings need delimiters. Try:

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

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+$/.

Example: http://ideone.com/Ec3zh

See also: PHP - Delimiters

preg_match php error - No ending delimiter '^' found

$exp should be something like /^[0-9]*$/ for it to work the way you intended. It is assuming ^ is your regex delimiter, because it is the first character - you'd want your first char to be something else. See preg_match manual entry for details.

preg_match(): No ending delimiter '/'

I think you are missing syntax here.You can use below pattern for your regular expression.

array('phone' => 'required', 'required|regex:/^\+?[^a-zA-Z]{5,}$/');

No ending delimiter '/' found error

The error is very clear really, you didn't include the trailing /:

preg_match('/<div id="resultStats">About \(.*?)\ /',$v,$s);

I honestly doubt your escape characters are well placed though. Maybe you meant \)?

PHP RegEx - no ending delimiter?

You need delimiters around your regex, usually /s:

if (preg_match("/^[A-Z0-9\-]{5}$/", $_GET['serial']) === false)
^---------------^

But any non-alphanumeric character is valid (even paired brackets), although it makes most sense to use ~, # or other symbols that aren't regex metacharacters or often used in text searches:

if (preg_match("#^[A-Z0-9\-]{5}$#", $_GET['serial']) === false)

In your case, as pointed out by Andy Lester, the regex engine thinks that ^ was supposed to be the delimiter (possible, but you then lose the "start of string" anchor for use in your regex and have to use \A instead):

if (preg_match("^\A[A-Z0-9\-]{5}$^", $_GET['serial']) === false)


Related Topics



Leave a reply



Submit