Last active
October 13, 2015 13:38
-
-
Save dalgard/7f01029db89751809bd2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This regex throws away anything between quotes at the root level, and captures | |
# anything between parentheses preceded by a keyword at the root level | |
# It uses this technique: http://www.rexegg.com/regex-best-trick.html | |
/ | |
(?: # Group | |
( \1 # Capturing group | |
['"] # Quotation mark | |
) | |
\1 # Previous quotation mark | |
| # Or | |
( \2 # Capturing group | |
['"] # Quotation mark | |
) | |
.*? # Lazy zero or more characters | |
[^\\] # Any character except backslash | |
\2 # Previous quotation mark | |
) | |
| # Or | |
( \3 # Capturing group | |
(?: # Optional group | |
\.{1,2} # One or two periods | |
\/ # One slash | |
)? | |
[\w\.-]+ # One or more characters | |
) | |
\( # Start parenthesis | |
( \4 # Capturing group | |
(?: # Zero or more of group | |
( \5 # Capturing group | |
['"] # Quotation mark | |
) | |
\5 # Previous quotation mark | |
| # Or | |
( \6 # Capturing group | |
['"] # Quotation mark | |
) | |
.*? # Lazy zero or more characters | |
[^\\] # Any character except backslash | |
\6 # Previous quotation mark | |
| # Or | |
[^)]* # Zero or more characters except end parenthesis | |
( \7 # Capturing group | |
['"] # Quotation mark | |
) | |
\7 # Previous quotation mark | |
| # Or | |
[^)]* # Zero or more characters except end parenthesis | |
( \8 # Capturing group | |
['"] # Quotation mark | |
) | |
.*? # Lazy zero or more characters | |
[^\\] # Any character except backslash | |
\8 # Previous quotation mark | |
)* | |
[^)]* # Zero or more characters except end parenthesis | |
) | |
\) # End parenthesis | |
/g |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment