RE: [PHP] Regex for telephone number
> 123 4567 > 1234567 > +91 44 123 4567 > +91 44 1234567 > 91-44-123 4567 > 91-44-1234567 So, 91441234567 and 9 1 4 4 1 2 3 4 5 6 7 aren't valid? You *could* apply a rule here, but it's fallible. 1. Strip out everything thats not a number (ereg_replace("[^0-9]", "")). 2. Count the number of digits. a. If there's less than 7 digits, its invalid. b. 7 digits is valid, local number format. c. 8, 9, and 10 digit numbers are invalid. d. 11 digits is valid, international format. Of course, if someone has a mobile phone this will fall flat on its face (in Australia, our phone numbers have 8 digits and our mobiles have 10 digits - this is the same in a number of countries). My advice, check that there's at least 7 digits and let it go. Jason -- Jason Murray [EMAIL PROTECTED] Web Design Team, Melbourne IT Fetch the comfy chair! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Regex for telephone number
Thanks for the reply. I'd like to ensure that numbers entered are in any of these formats: 123 4567 1234567 +91 44 123 4567 +91 44 1234567 91-44-123 4567 91-44-1234567 Number will be a minimum of 5 digits. TIA Vikram At 12:11 AM 1/16/01 +1100, Angus Mann wrote: >At 17:55 15/01/01 +0500, Vikram Vaswani wrote: >>Hi! >> >>Can someone help me out with a regex to validate a phone number? > >We'd need to know what format of telephone numbers you're looking to >validate, first. > >Angus. > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Regex for telephone number
> Can someone help me out with a regex to validate a phone number? That's a tough one, because 555- is just as valid as 1-800-BILLME. And here in Australia we have 131166 (yes, all you Aussies, that *IS* Pizza Hut's number... I couldn't think of any others :)) The best you can really do is make sure that its over a certain length. Jason -- Jason Murray [EMAIL PROTECTED] Web Design Team, Melbourne IT Fetch the comfy chair! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Regex for telephone number
case "phone_us": if(ereg("^([2-9][0-9]{2})([2-9][0-9]{2})([0-9]{4})$", $var)){ return TRUE; }else{ set_stringtypes_error(throw_error3("lib_string_types_108", $var)); } break; case "phone_int": if(!preg_match("/[^0-9\(\)\-\. ]/", $var)){ return TRUE; }else{ set_stringtypes_error(throw_error("lib_string_types_109", $var)); } break; works good for us. that's from the stringtypes lib in binarycloud. we're going to convert all of that stuff to be stored as rules in XML... groovy changes are afoot! _alex -- Alex Black, Head Monkey [EMAIL PROTECTED] The Turing Studio, Inc. http://www.turingstudio.com vox+510.666.0074 fax+510.666.0093 Saul Zaentz Film Center 2600 Tenth St Suite 433 Berkeley, CA 94710-2522 > From: [EMAIL PROTECTED] (Vikram Vaswani) > Newsgroups: php.general > Date: 15 Jan 2001 04:23:51 -0800 > Subject: [PHP] Regex for telephone number > > Hi! > > Can someone help me out with a regex to validate a phone number? > > Thanks > > Vikram > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Regex for telephone number
Hi! > Can someone help me out with a regex to validate a phone number? Read the examples at: http://www.php.net/manual/en/function.ereg-replace.php Der Heiko Buchtipp: http://www.aufbruch.com/ Heiko und Gisela Spallek: Aufbruch ins Land der unbegrenzten Moeglichkeiten. Studieren, Arbeiten und Leben in den USA: Tips fuer Neuankoemmlinge 2. erweiterte und ueberarbeitete Auflage: ISBN: 3-934407-01-3 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Regex for telephone number
At 17:55 15/01/01 +0500, Vikram Vaswani wrote: >Hi! > >Can someone help me out with a regex to validate a phone number? We'd need to know what format of telephone numbers you're looking to validate, first. Angus. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Regex for telephone number
Hi! Can someone help me out with a regex to validate a phone number? Thanks Vikram -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]