Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to split long regular expression rules to multiple lines in Python
    text
    copied!<p>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:</p> <pre><code>test = re.compile('(?P&lt;full_path&gt;.+):\d+:\s+warning:\s+Member\s+(?P&lt;member_name&gt;.+)\s+\((?P&lt;member_type&gt;%s)\) of (class|group|namespace)\s+(?P&lt;class_name&gt;.+)\s+is not documented' % (self.__MEMBER_TYPES), re.IGNORECASE) </code></pre> <p>Backslash or triple quotes won't work.</p> <p>EDIT. I ended using the VERBOSE more. Here's how the regexp pattern looks now:</p> <pre><code>test = re.compile(''' (?P&lt;full_path&gt; # 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&lt;member_name&gt; # 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&lt;function_name&gt; # 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 </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload