Skip to content

Instantly share code, notes, and snippets.

@selfsame
Created October 10, 2018 18:08
Show Gist options
  • Select an option

  • Save selfsame/c0ff1927ea035d2e0f6f2cdf2c37f808 to your computer and use it in GitHub Desktop.

Select an option

Save selfsame/c0ff1927ea035d2e0f6f2cdf2c37f808 to your computer and use it in GitHub Desktop.

Revisions

  1. selfsame created this gist Oct 10, 2018.
    8 changes: 8 additions & 0 deletions groups.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    >>> 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')