doug shawhan wrote:
> I've been looking through various sites, but cannot find the magic
> button that allows me to match a string with linefeeds
> I'd rather not strip out the linefeeds, then stick them back in. :-)
>
> I'm attempting something that should be fairly simple:
>
> snippy = re.compile('Hi there.*Bye there.')
For . to match a newline you have to compile with re.DOT_ALL:
snippy = re.compile('Hi there.*Bye there.', re.DOT_ALL)
>
> s = '''Good gravy! Hi there.
> I'm some text someone
> wants to match.
> Bye there. See you around'''
>
> yield = re.match (snippy)
re.match() only matches at the start of the string; use re.search()
Kent
>
> Anything after the linefeed is not matched, yielding naught but pain.
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Tutor maillist - [email protected]
> http://mail.python.org/mailman/listinfo/tutor
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor