Tuesday 15 July 2014

php - Whats wrong in regular expression -



php - Whats wrong in regular expression -

whats wrong with:

$pattern = '/9[0-5[7-9]]{1}[\\d]{10})|([0-2]\\d{11}/'; $subject = '971093342689';

trying check in php

preg_match($pattern, $subject)

receive error:

preg_match(): compilation failed: unmatched parentheses @ offset 22

the 2 parentheses not closed:

$pattern = '/9[0-5[7-9]]{1}[\\d]{10})|([0-2]\\d{11}/'; ^^^^

if sign need, have escape it. otherwise need open , closed parentheses in regexp.

php regex

No comments:

Post a Comment