Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: to get next line of pattern matched

by 2teez (Priest)
on Jan 07, 2013 at 09:25 UTC ( #1011988=note: print w/replies, xml ) Need Help??

in reply to to get next line of pattern matched

In a much as I will not recommend using regex to parse HTML doc., however, for this you could use Look-Around Assertions like so:

use warnings; use strict; my $str = "<div class='PlayVideo'></div> A8A <div class='RadioButtonClipStyle'>"; if ( $str =~ m#(?<=</div>)(.+?)(?=<div.+?>)#s ) { print $1; ## prints A8A }

If you tell me, I'll forget.
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author unknown to me

Replies are listed 'Best First'.
Re^2: to get next line of pattern matched
by ansh batra (Friar) on Jan 07, 2013 at 11:00 UTC

    your solution is correct but the file i am parsing contains many div tag
    can you please provide the more specific solution

      Since you're having so many problems achieving this with a regex, have you considered taking the previous advice of using a HTML Parser?

        ill surely consider that advice but i am about to complete something and at this point i am trying not to add any module to this if this is achivable using regular expressions

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1011988]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2016-10-22 16:45 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (297 votes). Check out past polls.