Skip to content

Instantly share code, notes, and snippets.

@z00sts
Created December 17, 2019 07:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save z00sts/a72066e83abebd605198654c31938ccc to your computer and use it in GitHub Desktop.
Save z00sts/a72066e83abebd605198654c31938ccc to your computer and use it in GitHub Desktop.
regex_verbose.py
_options_regex = re.compile(
r'''
(?P<keyword>[\w.-]+) # Consist of 1+ alphanumeric or '.' or '-'
\s*
(?P<settings> # Settings are optional
: # "Keyword/settings" delimiter
\s*
(?P<quote>"?) # Optional quote character
(?P<value>
(
(
(\\")
|
(\\;)
|
.
)+?
)
) # Value is a non greedy match
(?P=quote) # Matched quote character for the first one
)?
\s*
($|;) # Entry ends with ; or end of string
\s* # Spaces
''',
re.VERBOSE
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment