Top.Mail.Ru
October 12th, 2003 - Java developers — LiveJournal
? ?

Java developers

October 12th, 2003
 

11:24 am - Imagegrecianurn - Regular expressions

I've been trying to find a regular expression to validate phone numbers. The number must have 8 digits, and can have any number of spaces embedded in it.

The best I came up with was
"\\s*\\d\\s*\\d\\s*\\d\\s*\\d\\s*\\d\\s*\\d\\s*\\d\\s*\\d". This doesn't quite work, in any case, because it allows me to put in alphabets at the beginning or the end of the phone number.

Could anyone help me find a more efficient way of doing this? Thanks.
Powered by LiveJournal.com
Image