I have written following regular expression /^[A-Za-z0-9-_\s]*$/ in PHP which allows numbers, letters, spaces, hyphen and underscore. I want to display those matches which are not valid against the regex i.e “My Name is Blahblah!!!” should give me “!!!” output.
I have written following regular expression /^[A-Za-z0-9-_\s]*$/ in PHP which allows numbers, letters, spaces,
Share
Use the caret symbol inside the character class to invert the match and remove the start (
^) and end ($) characters:http://php-regex.blogspot.com/2008/01/how-to-negate-character-class.html