Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # This should be (mostly) RFC-compliant and is designed to allow for quick and
- # easy extraction of parameters. It does not allow an @ in the username, which
- # is allowed by the RFC (but probably no IRCds).
- # This pattern consumed several hours of my time. I had fun.
- message_re = re.compile(
- r'^(?P<message>' # This is really just to have it there.
- r'(?::(?P<sender>(?P<nick>[][a-zA-Z0-9_\\`{}^|-]+)' # nick
- r'(?:!(?P<user>[^\0\n\r @]+))?' # user
- r'(?:@(?P<host>[a-zA-Z0-9.-]+|' # host (next line is ipv6 address)
- r'(?:[0-9a-f]{0,4}:)+(?:(?:(?:\d{1,3}\.){3}\d{1,3})|[0-9a-f]{1,4})?))?|'
- r'(?P<server>[a-zA-Z0-9.-]+)) +)?' # server
- r'(?:(?P<command>[a-zA-Z]+)|' # command
- r'(?P<response>\d{3}))' # response
- r'(?: +(?P<params>(?P<middle>(?:(?!:)[^\0\n\r ]+ *?)*) *' # middle
- r'(?::(?P<trailing>[^\0\n\r]*))?))?)$' # trailing
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement