<html>
<body>
<h1>Regex Modifier: cat|dog|fish</h1>
<p>How many occurrences of either "cat", "dog", or "fish" are in the text "We have three dogs, one fish, but no cats":</p>
$txt = "We have three dogs, one fish, but no cats";
$pattern = "/cat|dog|fish/";
echo preg_match_all($pattern, $txt);
<p>The matches were found here:</p>
echo preg_replace($pattern, "#", $txt);
<p>(Each match was replaced by a # character)</p>
</body>
</html>
How many occurrences of either "cat", "dog", or "fish" are in the text "We have three dogs, one fish, but no cats":
3The matches were found here:
We have three #s, one #, but no #s(Each match was replaced by a # character)