-1
我想用xxx替换文本中每个出现的$(任何数字)。例如,如果在文本中出现$ 923,那么它应该是xxx。
模式我都试过
$string = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. $350 remaining essentially unchanged. It was popularised in the 1960s with the release of $90 required Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.";
$pattern = '/^\$[0-9]+\.?[0-9]?[0-9]/i';
$pattern = '/($\[0-9]+)/';
$replacement = "xxx";
echo preg_replace($pattern, $replacement, $string);
欢迎SO。 请阅读[我可以问哪些主题](http://stackoverflow.com/help/on-topic) 和[如何提出一个好问题](http://stackoverflow.com/help/how-to - 问) 和[完美的问题](http://codeblog.jonskeet.uk/2010/08/29/writing-the-perfect-question/) SO是**不是免费的编码或教程服务* *你必须表明你已经努力解决你自己的问题。 – RiggsFolly