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

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

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

 



reder
New User

Apr 16, 2007, 7:07 PM

Post #1 of 2 (1994 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.


osmodius
Novice

Apr 19, 2007, 11:15 AM

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

As far as I know,


Code
m/(<DIV>)(.+)(<\/DIV>)/sgi


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 admin@ub3r.net 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