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.
Use a different delimiter than /
-- it makes it confusing.
How about '#/\*.+?\*/#s'
;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With