Thanks, this works great! If you’re interested, here’s what I’m using it for:
$content = get_the_content();
echo preg_match_all("/$s/i", $content , $matches) . " instances of ".$s." found in the text.";
This would show how many times the search string appeared.
Anyways, thanks again!