I am having difficulty trying to get this regex to work. All I am trying to do is remove block comments. This is what I have so far but I can't get rid of the final */.
$string = 'this is a test /*asdfa */ ok then';
$pattern = '/\/\*([^\*\/]*)/i';
$replacement = '';
echo preg_replace($pattern, $replacement, $string);
//this is a test */ ok then
Any help will be appreciated.
/* a /* b */ echo 'see?'; */will out "see?" (or rather, the parser rejects it because of the final*/, which still proves the point. The SO syntax highlighter gets this right btw." this is a comment /* or is it? */". Should the comment inside the string be removed? Want to make it more complicated? Bring in some heredoc.