Given a string of text with phone numbers in it, return a unique'd cell array of strings that are the area codes.
s = '508-647-7000, (508) 647-7001, 617-555-1212';
then
a = {'508','617'}
Note: This problem refers to American-style phone numbers. You can assume the first three digits of a ten-digit number will always be the area code.
Solution Stats
Problem Comments
6 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers1072
Suggested Problems
-
Swap the first and last columns
22537 Solvers
-
796 Solvers
-
Calculate the Number of Sign Changes in a Row Vector (No Element Is Zero)
903 Solvers
-
702 Solvers
-
356 Solvers
More from this Author96
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
An explanation of common notations of area codes would be nice for us non-Americans :)
I (as French) Agree. A Wikipedia link which would explain supported area codes is definitely missing.
"You can assume the first three digits of a ten-digit number will always be the area code." Hmmm.... too bad there was no explanation applying to telephone numbers with more (or less?) than ten digits.
The problem fails to mention that the area codes should be sorted, and that phone numbers may have country codes.
This isn't about American-style phone numbers, but US-style. Otherwise it would be nice to include other test cases so people would be required to actually parse the country code away. Now it is just a matter of removing a leading 1.
Madness of cellfun regexp