Negate characters in Regular Expression
问题 How would I write a regular expression that matches the following criteria? No numbers No special characters No spaces in a string 回答1: The caret inside of a character class [^ ] is the negation operator common to most regular expression implementations (Perl, .NET, Ruby, Javascript, etc). So I'd do it like this: [^\W\s\d] ^ - Matches anything NOT in the character class \W - matches non-word characters (a word character would be defined as a-z, A-Z, 0-9, and underscore). \s - matches