In previous question, I have asked multiple matching patterns. Now my question is:
I have a few matching patterns:
$text =~ m#finance(.*?)end#s;
(1)
$text =~ m#<class>(.*?)</class>#s;
(2)
$text =~ m#/data(.*?)<end>#s;
(3)
$text =~ m#/begin(.*?)</begin>#s;
(4)
I want to match (1), (2) and (3) first. However, after matching (1) or (2), if (4) appears before another (1) or (2), then do not match (3) but only (4). So essentially (4)'s appearance excludes (3) from being matched. But in the case no (4) appears, (3) is matched. Is there any good way to do this?
Many thanks.