http://www.perlmonks.org?node_id=1011988


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