Skip to content

Instantly share code, notes, and snippets.

@selfsame
Created October 10, 2018 18:08
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 selfsame/c0ff1927ea035d2e0f6f2cdf2c37f808 to your computer and use it in GitHub Desktop.
Save selfsame/c0ff1927ea035d2e0f6f2cdf2c37f808 to your computer and use it in GitHub Desktop.
>>> p = r"rip (?P<thing>.+) from (?P<object>.+)"
>>> re.search(p, "rip sheet from red book")
<_sre.SRE_Match object; span=(0, 23), match='rip sheet from red book'>
>>> res = re.search(p, "rip sheet from red book")
>>> res.groups
<built-in method groups of _sre.SRE_Match object at 0x7fa2c61e2938>
>>> res.groups()
('sheet', 'red book')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment