[Tutor] re module and looping
Sean 'Shaleh' Perry
shalehperry@attbi.com
Fri, 11 Oct 2002 13:34:22 -0700
On Friday 11 October 2002 12:30, McCarney, James Alexander wrote:
> Magnus wrote:
>
> "Read the library manual. First of all, read about the
> difference between match and search. Then forget that ;)
> and use findall instead."
>
>
> Absolutely brilliant! ;-) Thanks Magnus...
>
> One glitch, however, is this. The code caught everything, except for th=
ese
> two tags:
> <!--
> and
> -->
>
> Which is where a script goes in the HTML...
>
> I would have thought
>
> p=3Dre.compile(r"(<.*?>)",re.DOTALL)
> m=3Dre.findall(r"(<.*?>)",alllines)
>
> would have returned everything, including <!-- and -->
>
it should *IF* the open and close is on the same line.
<fngvjkfvhdzifsndfsjik> will match
<fvjhfhsihsdfhzs
>
won't (the greater than sign is on the next line).