in reply to Pattern Match Problem

Maybe something like this:
#!/usr/bin/perl -wl use strict; while (<DATA>) { my $wanted; if (($wanted) = $_ =~ m/^gif"><\/td><td>(?:<b>)?([A-Z0-9\(\)\[\]]+ +?)<\/td>/) { print $wanted; } } __DATA__ gif"></td><td>XXX</td></tr> gif"></td><td>XXX</td></tr> gif"></td><td><b>XXX</td><td><b>yyy</td></tr>
Notes:

(?:<b>)?
- makes the <b> optional, and doesn't capture it

([A-Z0-9\(\)\[\]]+?)
- is where you capture your wanted string. Note the trailing +? - this makes it non-greedy, so that it only captures up until the first </td>

Having said the above, be aware that there are several CPAN modules available for parsing HTML.

Hope this helps,
Darren :)

Replies are listed 'Best First'.
Re^2: Pattern Match Problem
by Anonymous Monk on Mar 20, 2006 at 12:22 UTC
    thanks for that introduced me to a few new regex tricks Thanks

      Please also pay attention to the reply which avoids embeddded escaped delimeters.