I’m trying to validate a string (PHP & Regex) and I want option A to validate successfully but option B to not validate at all:
a) fsadgfsd!^_-@<><
OR
fsadgfsd!^_-@<>><
b) fsadgfsd!^_-@<>&;
OR
fsadgfsd!^_-@<>;&&;
So far I have this:
/^[a-zA-Z0-9 \!\^\_\@\<\>-]+$/
Which is validating everything for me except for the HTML encoded substrings of < and > and I’m hitting a brick wall with it at this stage, any help greatly appreciated.
Basically, in addition to my existing regex which is matching my special characters, I also need to be able to match the exact substrings of either < or > but not match the & or ; character on their own.
Due to restrictions in the code that I’m using, I’m not in a positon to be able to decode the data before validating it either…
\w is a shortcut for [a-zA-Z0-9_]
EDIT: without html_entity_decode