I am able to extract the tables with no problem using a pattern that includes all tables. But I am unable to tell regex that I want it only to match whenever <tr>.+</tr> is encountered three or more time.

Code

# this works: # this one extracts tables with rows no matter how many <tr> </tr> tags are in it $string =~ m|(<table[^>]*>.+?<tr[^>]*>.+?</tr[^>]*>.+?</table[^>]*>)|sig);