<?php
$teststring = <<<STR
aqbrakadabra
doom
<style>
<script>
sdgdfsf
<?php
<?
dfsaasdf
<? phpinfo(); ?>
STR;
print preg_replace("/\<\?(php){0,1}|(sys)[a-zA-Z0-9\s]+|(\?\>)|(.+)[;]|([\<][a-zA-Z0-9\/]+[\>])/iug","$$",$teststring);
//this expression returns no results even though $teststring has matching expressions
?>
At first I thought the problem was my regular expression or the specifics of preg_replace or preg_match - but as it turned out, the problem was much less complicated.