Created
March 15, 2017 19:59
-
-
Save trotzig/3a4797358800730a2351efe33428fbd6 to your computer and use it in GitHub Desktop.
Example of regex used in import-js before moving to babylon
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
REGEX_CONST_LET_VAR = / | |
\A | |
(?<declaration_keyword>const|let|var)\s+ # <declaration_keyword> | |
(?<assignment>.+?) # <assignment> variable assignment | |
\s*=\s* | |
(?<import_function>\w+?)\( # <import_function> variable assignment | |
(?<quote>'|") # <quote> opening quote | |
(?<path>[^\2\n]+) # <path> module path | |
\k<quote> # closing quote | |
\);? | |
\s* | |
\Z | |
/xm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment