January 28th, 2010, 01:52 PM
Regex Expression with special characters
I want to allow numberic and alphacharacters. I don't want to allow "#$%^&*()'" characters.
I've written that below and it seems to be working.
Now I want to add on top of that and don't allow these specific string characters: "amp;" "testing;"
So if you type "this is a amp; test" - it won't allow it. or "this is # testing;"
But if you type: "amp test" it will allow it.
So how do I add the code to the validation expression to check and not allow the specific string characters I have above?
January 28th, 2010, 02:27 PM
Regular expressions aren't really for that.
Do your character check with a regular expression, then do separate checks for the various substrings.
However, if you have a lot of them, regular expressions might be better - depends on the language.
January 28th, 2010, 02:50 PM
Is there a way to combine mine and your code into 1 regular expression?
When I just use ^((?!amp|testing);.)+$ it doesn't allow any characters. No numbers, letters anything.
Originally Posted by requinix