Update: My test case is as follows:
use strict; use warnings; my @strings; $strings[0] = "44 (1234) 123398 Ext 123"; $strings[1] = "+44 (1234) 123398 Ext 123"; $strings[2] = "44 (1234) 123398 Ext 123 xxxxxxxxxxxxxxx"; $strings[3] ="416-967-1111 ext. 123 xxxxxxxxxxxxxxxxx"; my $counter=0; for my $string (@strings) { if ($string =~/^(?:Ext|\d|\)|\(|\.|\s|\+|\-)+$/i) { print "$counter good\n"; } $counter++; }
Which returns:
0 good
It fails to match with a leading +, which I haven't got to the bottom of yet, but rejects all the wrong strings. (I'd missed out a vital |, which stopped the + matching - thanks to ysth for spotting it).
--------------------------------------------------------------
"If there is such a phenomenon as absolute evil, it consists in treating another human being as a thing."
John Brunner, "The Shockwave Rider".
In reply to Re^3: Tweak for my Perl Regex that screens for digits only
by g0n
in thread Tweak for my Perl Regex that screens for digits only
by hackermike
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |