I have a question about how regular expressions and PHP may be able to count the number of successful matches and output it or only do something once a minimum number of matches are found.
I am aware of a way of limiting a regular expression using something like {2,5} but I cannot get that to work, so I suppose that my only option is to use some sort of if statement that counts the number of matches from the regular expression and then does something if that number meets or exceeds what I specify.
$str = 'When we test this test it is testing whether the test is correct.';
if (preg_match_all('~test~', $str, $matches) > 3) {
echo '"Test" occurs more that 3 times';
} else {
echo '"Test" occurs 3 times or less';
}