I have the following regular expression... This one does not allow empty String. How do I have to manipulate?
var phoneReg = new RegExp(/^\+?[0-9]+(\([0-9]+\))?[0-9-]*[0-9]$/i);
Just use the "zero or one" operator ?, such as:
/^(?:regex)?$/
^
(?:regex) simply makes the concerned ground uncapturable (i.e. no need to change your $X, \X or ?X indexes if any).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With