假设我有一组字符[az]我想匹配集合中的每个字符,除了字符“a”谢谢!
[a-z-[e]]
means "any character between a and z except e". But as far as I know, only .NET, JGSoft and XML Schema support these " subtracted character classes ".
Another example:
[a-z-[aeiou]]
matches any (ASCII) consonant.
You can specify the character ranges as you want, for example:
[b-z]
This will only match the character from b
to z
. The only restriction is that it's a valid character range according to the character set that is used so that the first character has a lower code point than the second character.
Complete solution (ie no matter where the character is located in the [az] set and much more compatible):
[^\W\dA-Z && x]
Where "x" is the character (or group of characters, eg efgh) you want to exclude.
Tested on:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.