php – How to match and replace the source img with ../&# 39;

I want to delete any number of ../&# 39; in the source of the image (src).

I have a regular expression that suppresses ../&# 39; and also works if there is no ../&# 39; in the source.

<? php

$ help_path = & # 39; http: xxx.com/wp-content/help/&#39 ;;
$ contents = <<< MYVAR
WAS-Betjeningsboks-1-2-3

WAS-Betjeningsboks-1-2-3

WAS-Betjeningsboks-1-2-3













MYVAR;

$ find = array (
& # 39; #(.*?)# 39 ;, & # is
& # 39; #]*?) /?> # i & # 39;
)

$ replace = array (
& # 39;& # 39 ;,
& # 39;$ {2}& # 39;
)

$ preg_rep = preg_replace ($ find, $ replace, $ content);
print_r ($ preg_rep);

The problem is that my regular expression generates ../&# 39; there is more than one ../&# 39; in src. This should always be like src = "http://stackoverflow.com/Links/xxx.jpg", no matter how much of "../&# 39; are in the source (& # 39; ../../../../&# 39;).

WAS-Betjeningsboks-1-2-3

WAS-Betjeningsboks-1-2-3

WAS-Betjeningsboks-1-2-3