in reply to Pattern Match Problem

while (<DATA>) { print "$1\n" if m/gif"><\/td><td>(?:<b>)?([A-Z0-9\(\)\[\]]+)(?:<\/ +b>)?<\/td>(?:<td>(?:<b>)?([A-Z0-9\(\)\[\]]+)(?:<\/b>)?<\/td>)?<\/tr>/ +; } __DATA__ gif"></td><td>XXX</td></tr> gif"></td><td><b>XXX</td></tr> gif"></td><td><b>XXX</b></td></tr> gif"></td><td><b>XXX</td><td><b>YYY</td></tr>
This should do what you want, and it takes care of all the <b> and </b> cases. Don't ask me to explain it, though.