I have this regular expression :
^(1?)(-| ?)(\()?([0-9]{3})(\)|-| |\)-|\) )?([0-9]{3})(-| )?([0-9]{4}|[0-9]{4})$
I want to allow dashes (“-“) anywhere inside the string.
what is the best way to do it ?
Source:
http://www.regxlib.com/REDetails.aspx?regexp_id=1497
I’d say the best would be changing parts like
into
This means there are 3 numbers, each may be followed by a dash. If you want to allow multiple dashes there, change
?to*.