I'm looking to reformat (replace, not validate - there are many references for validating) a phone number for display in Javascript. Here's an example of some of the data:
- 123 4567890
- (123) 456-7890
- (123)456-7890
- 123 456 7890
- 123.456.7890
- (blank/null)
- 1234567890
Is there an easy way to use a regular expression to do this? I'm looking for the best way to do this. Is there a better way?
I want to reformat the number to the following: (123) 456-7890