The regular expression ^((\\(\\d{3}\\) ?)|(\\d{3}-))?\\d{3}-\\d{4}$ matches strings of the form XXX-XXX-XXXX and XXX-XXXX (am I missin
^((\\(\\d{3}\\) ?)|(\\d{3}-))?\\d{3}-\\d{4}$
XXX-XXX-XXXX
XXX-XXXX
^(((\d{3}) ?)|(\d{3}-))?\d{3}-\d{4}$^
this will work.