Skip to content

Instantly share code, notes, and snippets.

@pcarrier
Created November 26, 2011 23:31
Show Gist options
  • Save pcarrier/1396505 to your computer and use it in GitHub Desktop.
Save pcarrier/1396505 to your computer and use it in GitHub Desktop.
LINK_MATCHER = re.compile(r"""
^
(?P<num> [0-9] +?) :
\ (?P<name> [^:] +?) :
\ <(?P<flags> [^>] +?)> # uppercase, comma-separated list of flags
\ (?P<extra> . *?) # space-separated pairs of "key value"
\ *\\\ *
\ *link/(?P<link> [^ ] +?)
\ (?P<addr> [0-9a-f:] +?)
\ brd\ (?P<brd> [0-9a-f:] +?)
$
""", re.X | re.M)
ADDR_MATCHER = re.compile(r"""
^
(?P<num> [0-9] +?) :
\ (?P<name> [^ ] +)
\ +
(?P<type> [^ ] +)
\ (?P<addr> [^ ] +)
(?:
\ brd\ (?P<brd> [^ ] +)
)?
\ scope\ (?P<scope> [^ ] +)
(?:
\ (?P<alias> [^\\] [^ ] +)
)?
(?:
\ \\\ +
(?P<extra> . *?)
)?
$
""", re.X | re.M)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment