您走在正确的轨道上,也许可以使用前瞻,并且模式的开始也正确,但是它缺少一些东西。考虑这个版本:^\D(?=.*\d{2})\w{4,}$下面是对模式的解释:^ from the start of the string \D match any non digit character (?=.*\d{2}) then lookahead and assert that two consecutive digits occur \w{4,} finally match four or more word characters (total of 5 or more characters)$ end of the string您当前尝试中缺少的主要部分是它在开头仅匹配一个非数字字符。您需要提供一个可以匹配 5 个或更多字符的模式。