Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make skip pattern into a subroutine #2

Open
laowantong opened this issue Nov 20, 2019 · 0 comments
Open

Make skip pattern into a subroutine #2

laowantong opened this issue Nov 20, 2019 · 0 comments
Assignees

Comments

@laowantong
Copy link
Owner

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 laowantong self-assigned this Nov 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant