Answer the question
In order to leave comments, you need to log in
PHP + RegExp, character range search with exception
Hello. Please tell me how to write the regular expression [az[^sgm]] in php (non-working example), i.e. all characters from range az except characters sgm?
I found something similar with character classes ( www.php.net/manual/ru/regexp.reference.character-classes.php ): [12[:^digit:]], but I need certain characters, not classes.
Answer the question
In order to leave comments, you need to log in
You can try this:
/^[^\Wsgm]+$/
Explanation: \W means all characters not included in the word, ^ inverts this class, i.e. \W becomes \w and also excludes sgm characters following \W from the current class.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question