Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有以下正则表达式:
[a-z][^b|j|m|n]{5}
但是,它只匹配 6 个字符而不是指定的 5?
[^b|j|m|n]{5}将匹配 5 个字符,并且[a-z]将是第 6 个。
[^b|j|m|n]{5}
[a-z]
您可能想使用
[ac-iklo-z]{5}
反而。这只会匹配所有五个字符的所需字符。如果您确实想匹配“任何字母字符后跟除 b、j、m、n 之外的任何单个字符”总共五个字符,那就是
[a-z][^bjmn]{4}