Php preg_replace encounters a situation that does not match, the reason for asking for help

php preg_replace replacement code is as follows

$_POST["content"] = preg_replace("/<\s*img(.*)".preg_quote($value["name"])."(.*)>/iUs", "<img src="". $attach["bigimg"] ."" />", $_POST["content"]);

now there is a situation that cannot be matched, and one"s knowledge and ability cannot find the reason. Solve the confusion and solve the problem

$_ POST ["content"] is as follows:

<p class="f_center"><img alt="" src="data/attachment/portal/201810/21/201810thxuzgsx0zl.jpeg" style="margin: 0px auto; display: block;" />

$value ["name"] is as follows

data/attachment/portal/201810/21/201810thxuzgsx0zl.jpeg

$attach ["bigimg"] is as follows:

data/attachment/portal/201810/21/150051az6bl1ialal1sqay.jpeg

Why doesn"t it match? Also ask the great god to solve the doubt, thank you very much!

Sep.08,2021

notice that the error log is checked.
the problem is located on the regular expression by Unknown modifier 'a'.

check the regular expression, locate where an appears, and data/attachment an appears here, considering the symbol / not escaped

look up the manual preg_quote manual for instructions / not regular expression special characters, here / only our pattern delimiter, can also be specified as-sharp

therefore, the second parameter is required for preg_quote. For more information, please see preg_quote

.
Menu