Characters that are not within a range can be matched by complementing the set. If the first character of the set is '^', all the characters that are not in the set will be matched. For example, [^5] will match any character except '5', and [^^] will match any character except '^'. ^ has no special meaning if it’s not the first character in the set.
[^a-zA-Z-]
除了a-z,a-z或者破折号
见regular expression syntax
[^a-zA-Z]
表示匹配不在a-z或a-z范围内的任何字符如果您还想排除
-
,请包括它:[^a-zA-Z-]
如果这是你现在的正则表达式
如果要排除
-
,请使用[]
开头的插入符号表示“不在此字符类中”。因此,将-
添加到集合中会将其排除在匹配之外相关问题 更多 >
编程相关推荐