php - How to replace a portion of string with a dot in regex? -
here string want replace:
<img src="./handler_image.php?i=c52bc1c30f560f4a15f99eeb8c04fea6" alt="favicon" class="favicon"> i wrote code:
$answer = preg_replace('/<img src="\./.*?>/', '', $answer); but not work. if replace with:
$answer = preg_replace('/<img src=".*?>/', '', $answer); it works replaces images , not ones src in format above. how should modify statement?
the forward slash after dot needs escaped too.
try this:
$answer = preg_replace('/<img src="\.\/.*?>/', '', $answer);
Comments
Post a Comment