Regular Expressions and RFC 822
David LeBlanc
whisper at oz.net
Sun May 19 17:36:55 EDT 2002
import re
pat = r"([A-Za-z -]*):(.*)"
cpat = re.compile(pat)
result = cpat.match("Return-Path: <python-list-admin at python.org>")
for group in result.groups():
print group
>>>
Return-Path
<python-list-admin at python.org>
David LeBlanc
Seattle, WA USA
> -----Original Message-----
> From: python-list-admin at python.org
> [mailto:python-list-admin at python.org]On Behalf Of alex gigh
> Sent: Sunday, May 19, 2002 14:04
> To: python-list at python.org
> Subject: Regular Expressions and RFC 822
>
>
> Hi;
>
> I am trying to write a mail server in Python and I found out that
> I can use
> regular expressions and then grouping:
>
> "For example, an RFC-822 header line is divided into a header name and a
> value, separated by a ":". This can be handled by writing a regular
> expression which matches an entire header line, and has one group which
> matches the header name, and another group which matches the
> header's value.
> "
>
> Can someone help me by showing me an example of how I could do this...
>
> Many Thanks
>
> Alex
>
> _________________________________________________________________
> Get your FREE download of MSN Explorer at
> http://explorer.msn.com/intl.asp.
>
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
More information about the Python-list
mailing list