Created
July 24, 2021 13:07
-
-
Save MystPi/62190417be0eea51a8a2ce03216a2c78 to your computer and use it in GitHub Desktop.
A regex to parse escaped strings.
This file contains hidden or 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
import re | |
regex = re.compile(r'(["\']).*?(?<!\\)(\\\\)*?\1') |
I made a slightly simpler regex:
/("|')[^\\\n]*?(\\\\)*\1/g
Oh, nice!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think I understand how it works. This is pretty cool