paroxython icon indicating copy to clipboard operation
paroxython copied to clipboard

Make skip pattern into a subroutine

Open laowantong opened this issue 4 years ago • 0 comments

For instance, the construct index:

          ^(.*?)/_type='Subscript'
\n(?:\1.+\n)*?\1/lineno=(?P<LINE>\d+)
\n(?:\1.+\n)*?\1/slice/_type='Index'

... could be expressed as:

^(.*?)/_type='Subscript'
      (?(DEFINE)(?P<sq>\n(?:\1.+\n)*\1))
(?&sq)/lineno=(?P<LINE>\d+)
(?&sq)/slice/_type='Index'

To further mute the regex noise, the definition could be injected dynamically after the first closing parens.

laowantong avatar Nov 20 '19 15:11 laowantong