Philippine validating test

6854933580_2c8b688306_z

:\(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*\)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(? When you match,

:\(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*\)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(? When you match, $1 contains the area code, $2 and $3 contain the phone number, and $5 contains the extension. Do you foresee any need to allow square, curly, or angled brackets for some regions? If you want to maintain per digit rules (such as in US Area Codes and Prefixes (exchange codes) must fall in the range of 200-999) well, good luck to you. I came up with this: Here's a perl script to test it. It should be compatible with international numbers and localization formats.

||

:\(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*\)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(? When you match, $1 contains the area code, $2 and $3 contain the phone number, and $5 contains the extension. Do you foresee any need to allow square, curly, or angled brackets for some regions? If you want to maintain per digit rules (such as in US Area Codes and Prefixes (exchange codes) must fall in the range of 200-999) well, good luck to you.

I came up with this: Here's a perl script to test it. It should be compatible with international numbers and localization formats.

STRINGENT IMPLEMENTATION OF CITY ORDINANCE 2004-184: ANTI-SMOKING ORDINANCE SUPPORTING EXECUTIVE ORDER NO.26: PROVIDING FOR THE ESTABLISHMENT OF SMOKE-FREE ENVIRONMENT IN PUBLIC AND ENCLOSED PLACES, AND REPUBLIC ACT NO.

9211: THE TOBACCO REGULATION ACT OF 2003LIST OF NAMES OF FACILITATORS, PARTICIPANTS AN SCHEDULES ON REGION WIDE TRAINING ON THE ENHANCEMENT OF THE PEDAGOGICAL SKILLS IN TEACHING READING IN THE MOTHER TOUNGUE AND THE BRIDGING PROCESS OF GRADE 1 AND KINDERGARTEN TEACHERSSEVEN-DAY MASS TRAINING ON UNTRAINED TVL SENIOR HIGH SCHOOL TEACHER (THIRD TRANCHE) (TRAINER/FACILITATOR)SEVEN-DAY MASS TRAINING ON UNTRAINED TVL SENIOR HIGH SCHOOL TEACHER (THIRD TRANCHE) (TRAINER/FACILITATOR)FINAL SUBMISSION OF SELECTED ATHLETES AND SCREENING OF DOCUMENTS IN PREPARATION FOR THE QUALIFYING SPORTS COMPETITION FOR THE 2018 SOUTHERN TAGALOG CALABARZON ATHLETICS ASSOCIATION (STCAA) MEET (DEPED RIZAL AND ANTIPOLO)ADDENDUM AND CORREGENDUM TO THE UNNUMBERED MEMORANDUM DATED OCT.

So far, it's been working with everything they've thrown at it, but if errors come up, I'll update this answer.

Regex: Here's a wonderful pattern that most closely matched the validation that I needed to achieve.

-Adam After reading through these answers, it looks like there wasn't a straightforward regular expression that can parse through a bunch of text and pull out phone numbers in any format (including international with and without the plus sign).

Here's what I used for a client project recently, where we had to convert all phone numbers in any format to tel: links.

contains the area code, and contain the phone number, and contains the extension. Do you foresee any need to allow square, curly, or angled brackets for some regions? If you want to maintain per digit rules (such as in US Area Codes and Prefixes (exchange codes) must fall in the range of 200-999) well, good luck to you. I came up with this: Here's a perl script to test it. It should be compatible with international numbers and localization formats.

You've correctly identified that it's a tricky problem...

If he does not want to give it to you then forcing him to enter a valid number will either send him to a competitor's site or make him enter a random string that fits your regex.

$ If the user wants to give you his phone number, then trust him to get it right.

And while stripping all/most non-numeric characters may work well on the server side (especially if you are planning on passing these values to a dialer), you may not want to thrash the user's input during validation, particularly if you want them to make corrections in another field.

My test script downloads a file from the internet and prints all the phone numbers in it. Maintaining a complex rule-set which could be outdated at any point in the future by any country in the world does not sound fun.

I'm not the original author, but I think it's well worth sharing as I found this problem to be very complex and without a concise or widely useful answer.

You must have an account to comment. Please register or login here!