What i am trying to do is to not allow two consecutive special characters like &* or *$ or &&, but it should allow special characters in between strings like Hello%Mr&.
What i have tried so far:
^(([\%\/\\\&\?\,\'\;\:\!\-])\2?(?!\2))+$
^(?!.*[\%\/\\\&\?\,\'\;\:\!\-]{2}).*$
The idea is to use a negative lookahead ((?!)) to verify that nowhere in the string (.*) are there two consecutive "special" characters ([...]{2}). Afterwards, you just match the entire string (.*).
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