-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