Is this actually doable? I have some very long regex pattern rules that are hard to understand because they don't fit into the screen at once. Example:
test = re.compile('(?P<full_path>.+):d+:s+warning:s+Members+(?P<member_name>.+)s+((?P<member_type>%s)) of (class|group|namespace)s+(?P<class_name>.+)s+is not documented' % (self.__MEMBER_TYPES), re.IGNORECASE)
Backslash or triple quotes won't work.
EDIT. I ended using the VERBOSE mode. Here's how the regexp pattern looks now:
test = re.compile('''
(?P<full_path> # 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+parameterssofsmembers+ # An almost static string
(?P<member_name> # 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<function_name> # 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+aresnots(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
question from:
https://stackoverflow.com/questions/8006551/how-to-split-long-regular-expression-rules-to-multiple-lines-in-python 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…