I need regex to search string for alphanumeric, (, ), -, ., / and ampersand(&).
Right now i m using this regex in client side validation
[^A-Za-z0-9.)(/-\&]
EDIT:
I want to search my string for special characters VAL.search(/[^A-Za-z0-9.)(/-\&]+/g)==-1
Thanks. @RandomCoder_01 actually, no escapes are needed. & is not a special regex character, so no need to escape it.
This answer is not useful. Show activity on this post. $& (dollar ampersand) holds the entire regex match. $' (dollar followed by an apostrophe or single quote) holds the part of the string after (to the right of) the regex match. $` (dollar backtick) holds the part of the string before (to the left of) the regex match ...
With some variations depending on the engine, regex usually defines a word character as a letter, digit or underscore. A word boundary \bdetects a position where one side is such a character, and the other is not.
Escape the backslash, put the dash at the end of the character class.
[^A-Za-z0-9.)(/\\&-]
Not sure why you included ^
, as this negates the character class.
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