in reply to Re: Matching set of paragraph tags with string inside.
in thread Matching set of paragraph tags with string inside.

My problem with the first match is it matches too much...
original: "<p>no tabs here</p><p>column 1[tab]column 2</p><p>no tabs here</p>" result of first regex: no tabs here</p><p>column 1[tab]column 2
What I want it to match is...
column 1[tab]column 2
Since that is the set of para's with the string [tab].

Replies are listed 'Best First'.
Re^3: Matching set of paragraph tags with string inside.
by moritz (Cardinal) on Feb 08, 2008 at 21:20 UTC
    My first shot was too fast, here's a working solution:
    my $contents = "<p>no tabs here</p><p>column 1[tab]column 2</p><p>no t +abs here</p>"; if ($contents =~ m{(<p>[^<>]*\[tab\][^<>]*</p>)} ){ print "Matched '$1'\n;"; }