Regular Expression (Regex) for Phone Numbers – International and U.S. Formats

I have been looking all over the web for a regular expression to use in JavaScript functions to help with formatting phone number links and printing phone numbers on pages for iPhones, Android, and other mobile devices. This process would naturally affect traditional internet browsers for traditional computers but I went down this path mostly for tracking phone number touch events in Google Analytics on only mobile devices. I finally had the epiphany today that created one expression that covered most international and United States phone number formats.

International and U.S. Phone Number Regular Expression

The red areas, represent the numbered portions. Areas in gray represent the options for spaces, dashes, periods, or sometimes nothing between numbers (e.g. the question marks).

Continue reading “Regular Expression (Regex) for Phone Numbers – International and U.S. Formats”