[Tutor] another re question

Hy Python pythonpython@hotmail.com
Fri, 05 Oct 2001 04:21:25 +0000


what if it's like this:
html="""
<html>
<head>
blahhhhhhlaaaa
</head>
<body>
blahlbaaalalablaaa
<script language="JavaScript">
blahblahblahblahblahblahblah
blahblahblahblah
blahblahblahblah
</script>
dasdfas sdafblala
balalala
sddsfasdf
<script language="JavaScript">
blahblahblahblahblahblahblah
blahblahblahblah
blahblahblahblah
</script>
</body>
</html>
"""

How can I do a re.findall ?
I used this:
re.findall(r"\n?<script[^>]+?>.+?</script>",html)
it does not work. Why?


Thanks a lot..

Hy


>From: Ignacio Vazquez-Abrams <ignacio@openservices.net>
>To: <Tutor@python.org>
>Subject: Re: [Tutor] a re question
>Date: Thu, 4 Oct 2001 23:41:43 -0400 (EDT)
>
>On Fri, 5 Oct 2001, Newbie Python wrote:
>
> > How can use re to match something like:
> > js="""
> > <script language="JavaScript">
> > blahblahblahblahblahblahblah
> > blahblahblahblah
> > blahblahblahblah
> > </script>
> > """
> >
> > I use this:
> > re.match(r"<script.+?</script>",js,re.S)
> > but it will not match..
> >
> > Can you please tell me why and how to write the regex?
>
>There's a newline in the beginning of your string. Use
>".*<script[^>]*>.*</script>.*" instead.
>
>--
>Ignacio Vazquez-Abrams  <ignacio@openservices.net>
>
>
>_______________________________________________
>Tutor maillist  -  Tutor@python.org
>http://mail.python.org/mailman/listinfo/tutor


_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp