这实际上可行吗?我有一些非常长的正则表达式规则,很难理解,因为它们不能一次融入屏幕。例:
test = re.compile('(?P.+):\d+:\s+warning:\s+Member\s+(?P.+)\s+\((?P%s)\) of (class|group|namespace)\s+(?P.+)\s+is not documented' % (self.__MEMBER_TYPES), re.IGNORECASE)
反斜杠或三重引号将无法正常工作。
编辑。我结束了使用VERBOSE更多。以下是正则表达式模式现在的样子:
test = re.compile('''
(?P # Capture a group called full_path
.+ # It consists of one more characters of any type
) # Group ends
: # A literal colon
\d+ # One or more numbers (line number)
: # A literal colon
\s+warning:\s+parameters\sof\smember\s+ # An almost static string
(?P # Capture a group called member_name
[ #
^: # Match anything but a colon (so finding a colon ends group)
]+ # Match one or more characters
) # Group ends
( # Start an unnamed group
:: # Two literal colons
(?P # Start another group called function_name
\w+ # It consists on one or more alphanumeric characters
) # End group
)* # This group is entirely optional and does not apply to C
\s+are\snot\s\(all\)\sdocumented''', # And line ends with an almost static string
re.IGNORECASE|re.VERBOSE) # Let's not worry about case, because it seems to differ between Doxygen versions