假设我有以下字符串,并且我想提取以大写字母开头的所有标识符,除非在引号内找到:
Match1
Match2(Match3("NoMatch1 a NoMatch2 blabla"), Match4)
meh<Match5>
在这种情况下,Match1、Match2、Match3、Match4和Match5应该被捕获,而NoMatch1和NoMatch2应该被忽略,因为它们位于带引号的字符串内。
我可以使用 JS 正则表达式获得所需的结果。但是我所有将其转换为有效的 Python 正则表达式的尝试都惨败。到目前为止我遇到的错误消息:
( A lookbehind assertion has to be fixed width
* A quantifier inside a lookbehind makes it non-fixed width
) A lookbehind assertion has to be fixed width
* A quantifier inside a lookbehind makes it non-fixed width
我不知道如何解决这个问题。使用 Python 正则表达式可以实现这一点吗?如果是这样,我错过了什么?
注意:我还没有实际的 Python 代码,到目前为止我一直在https://regex101.com上尝试这一点。
天涯尽头无女友
子衿沉夜
随时随地看视频慕课网APP
相关分类