On Friday, May 27, 2011 6:47:21 AM UTC-7, Roy Smith wrote: > In article <948l8n...@mid.individual.net>, > Gregory Ewing <greg....@canterbury.ac.nz> wrote: > > > John Bokma wrote: > > > > > A Perl programmer will call this line noise: > > > > > > double_word_re = re.compile(r"\b(?P<word>\w+)\s+(?P=word)(?!\w)", > > > re.IGNORECASE) > > One of the truly awesome things about the Python re library is that it > lets you write complex regexes like this: > > pattern = r"""\b # beginning of line > (?P<word>\w+) # a word > \s+ # some whitespace > (?P=word)(?!\w) # the same word again > """ > double_word_re = re.compile(pattern, re.I | re.X)
Perl has the X flag as well, in fact I'm pretty sure Perl originated it. Just saying. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list