By Kevin Zhao
US phone numbers are organized as (XXX)-YYY-ZZZZ, where XXX is the area code, YYY and ZZZZ are your main number bodies.
My function extractNumberFormat returns the standardized US number format from the input string, such that it follows the phone format. You can omit any hyphen or the parenthesis pair, add any space among XXX, YYY, ZZZZ. However, you cannot write only half of the parenthesis pair, or add space within numbers of XXX, YYY, ZZZZ.
(212) -998 1212
212 9981212
212 998 - 1212
(212 -998 1212
(212)-9981-212
(212)-99-212
each returns:
(212)-998-1212
(212)-998-1212
(212)-998-1212
Not Valid US Phone
Not Valid US Phone
Not Valid US Phone