in reply to How do I parse a telephone number?

Based on jlistf's answer:

( undef, $areacode, $exchange, $line ) = $phn =~ m|(1-)?\(?(\d{3})\)?-?(\d{3})-(\d{4})|;
Works on strings such as the following:
212-555-1212 (212)555-1213 1-(212)-555-1214 1-212-555-1215

Originally posted as a Categorized Answer.