I need a regular expression supporting alphanumeric, hyphen, hyphen-space-hyphen, + and ++.
For the alphanumeric with hyphen, space and plus, I can give something like /^[a-zA-Z0-9- +]*$/. Can I use +{0,2} inside the square bracket?
Anybody please help me to complete my required regular expression.
Try this:
^(\+{0,2}[a-zA-Z0-9\-]+)*\+{0,2}$
It will accept +ab, ++ab, ++ab++, ++ab++a+, etc., but it will not accept +++a, ++ab+++, etc.
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