preg_replace <*>

2019-07-21 17:25发布

问题:

How do I change all occurrences of <*> in every line of a text file (a total of 5 <*> in every line) using preg_replace (substituting it with, say, |)?

My code is:

preg_replace("/<*\>/", "|", $text);

回答1:

You shoud escape the *

preg_replace("/<\*>/", "|", $text);