Naming Back References
Posted: Fri Jun 17, 2005 3:48 pm
In searching for form validation patterns, I came across the following phone number pattern that is VERY tolerant (allows, brackets, hyphens, x|X|Ext for extensions,e tc..)
My question is this... Where can I learn about naming the back references (and any other advanced things like it), I have yet to see anything about it in all the sites/tutorials/howto's/etc that i've seen. (and i'm not taking regex in school until next semester
)
<edit> phone validation not email
</edit>
Code: Select all
$pat = '#^(?:(?P<1>ї(])?(?P<AreaCode>ї2-9]\d{2})(?(1)ї)]ї ]?|ї- \/.]?))?(?P<Prefix>ї1-9]\d{2})ї- .]?(?P<Suffix>\d{4})(?:(?:ї ]+|\s*?x\s*?|\s*?ext\s*?\.?ї ]?){1,2}(?P<Ext>\d{1,5}))?$#i';Code: Select all
$val = "e;905-945-0971x1234"e;;Code: Select all
Array
(
ї0] => 905-945-0971x1234
ї1] =>
ї2] =>
їAreaCode] => 905
ї3] => 905
їPrefix] => 945
ї4] => 945
їSuffix] => 0971
ї5] => 0971
їExt] => 1234
ї6] => 1234
)<edit> phone validation not email