I am pretty new to regular expressions. I want to write a regular expression which validates whether the given string has only certain characters. If the string has any other characters than these it should not be matched.
The characters I want are:
& ' : , / - ( ) . # " ; A-Z a-z 0-9
Try this:
$valwill match if it has at least one character and consists entirely of characters in that character set. An empty string will not be matched (if you want an empty string to match, change the last+to a*).You can test it out yourself:
Some examples: