in reply to Tweak for my Perl Regex that screens for digits only

$number =~ /^\s*(\(\d{3}[)\-]\s*)?\d{3}\-?\d{4}(\s*ext[\.\:]?\s*\d+)?\ +s*$/i
I haven't tested it, but it should allow:

Replies are listed 'Best First'.
Re^2: Tweak for my Perl Regex that screens for digits only
by ikegami (Patriarch) on Jan 25, 2006 at 18:10 UTC
    • It doesn't match 416-967-1111. This format is used more than (416) 967-1111 here.
    • It doesn't match when the country code is supplied. (e.g. 1-416-967-1111)
    • It doesn't match x as the extention seperator. (e.g. ... x330)
    • It doesn't (necessarily) match any numbers from outside of North America.
Re^2: Tweak for my Perl Regex that screens for digits only
by hackermike (Novice) on Jan 25, 2006 at 18:49 UTC
    Thanks for your input
    The thing is that there is NO intention to force ANY number format or sequence, no intention to "validate" that it is a "real" phone number or match any particular country format, etc.

    All that is intended is that the user has to enter only digits and punctuation, any way they choose, any number of digits or sets of digits and punctuation. The only exception I'd like to allow is only the characters ext. and/or Ext.