Create a string array of all comments in a html file...

William James w_a_x_man at yahoo.com
Sun Sep 30 14:37:51 EDT 2007


On Sep 30, 10:39 am, sophie_newbie <paulgeele... at gmail.com> wrote:
> Hi, I'm wondering how i'd go about extracting a string array of all
> comments in a HTML file, HTML comments obviously taking the format
> "<!-- Comment text here -->".
>
> I'm fairly stumped on how to do this? Maybe using regular expressions?
>
> Thanks.

E:\Ruby>irb --prompt xmp
"<!-- Comment
here -->And <i>so</i> funny!
<p>It was a dark and stormy night.
</p><!-- Comment <> -->".scan(/<!--.*?-->/m)
    ==>["<!-- Comment\nhere -->", "<!-- Comment <> -->"]




More information about the Python-list mailing list