使用 re 在 python 中进行部分字符串匹配

Partial string matching in python using re

匹配所有小写字母,后跟两个或更多大写字母,然后是三个或更多数字:(匹配中不应包括大写字母和数字)in python

我试过了但没有用:[a-z]?![A-Z]{2,}[0-9]{3,}。

使用您当前的方法,但将大写字母后跟数字断言置于正向预测中:

[a-z](?=[A-Z]{2,}[0-9]{3,})

此模式表示:

[a-z]          match a lowercase letter
(?=            then lookahead (but do NOT consume)
    [A-Z]{2,}  2 or more uppercase letters
    [0-9]{3,}  followed by 3 or more digits
)

Lookaheads assert,但不是 consume,在正则表达式模式中。