⭐ in reply to How do I parse a telephone number?
Here's an answer that allows the use of spaces instead of dashes, or no spacing at all.
Works on strings such as the following:( $areacode, $exchange, $line ) = $phn =~ m/(1[-| ]?)?\(?(\d{3})\)?[-| ]?(\d{3})[-| ]?(\d{4})/;
212-555-1212 (212)555-1213 1-(212)-555-1214 1-212-555-1215 212 555 1216 (212) 555 1217 1 (212) 555 1218 1 212 555 1219 12125551210
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: Answer: How do I break down a phone number and rebuild it?
by Ovid (Cardinal) on Jul 11, 2000 at 22:06 UTC |