[Tutor] Tutor Digest, Vol 53, Issue 13
Kent Johnson
kent37 at tds.net
Tue Jul 8 13:23:09 CEST 2008
On Sun, Jul 6, 2008 at 5:09 AM, Lie Ryan <lie.1296 at gmail.com> wrote:
> The string implicit string concatenation exist for things like verbose
> re (regular expression):
>
> import re
> re.compile(
> '<' # Start opening tag
> '\s*' # Arbitrary whitespace
> '(.*?)' # tagname
> '\s*' # Arbitrary whitespace
> '(.*?)' # Values
> '>', # Start closing tag
> re.VERBOSE
> )
VERBOSE regular expressions can contain comments; this could be written as
re.compile('''
< # Start opening tag
\s* # Arbitrary whitespace
(.*?) # tagname
\s* # Arbitrary whitespace
(.*?) # Values
>''', # Start closing tag
re.VERBOSE
)
Kent
More information about the Tutor
mailing list