CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Regular Expressions:
HTML Tag Regex.


New User

Apr 16, 2007, 7:07 PM

Post #1 of 2 (6980 views)
HTML Tag Regex. Can't Post

I have been away from perl for a while and am stuck on the following:

I have a html string. Somewhere in the string there will be one or more sets of <DIV> and </DIV> tags. I need a regex that will grab the outer most opening and closing tags and all the content between them.

eg :

"<FONT face=Tahoma size=2>
<DIV>The first message...</DIV>
<DIV>The second message....</DIV></FONT>"

I want to capture :

<DIV>The first message...</DIV>
<DIV>The second message....</DIV>

Any help would be great, Thank you.


Apr 19, 2007, 11:15 AM

Post #2 of 2 (6975 views)
Re: [reder] HTML Tag Regex. [In reply to] Can't Post

As far as I know,


should work. $2 will contain everything within the two div tags.

You can also use the HTML::Parser module to this effect.

Need some real-time help? Shove on yer MSN.

(This post was edited by osmodius on Apr 19, 2007, 11:22 AM)


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives