PHP preg_替换以$by xxx开头的任何数字

PHP preg_替换以$by xxx开头的任何数字,php,str-replace,Php,Str Replace,我想用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 unknow

我想用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);
试试这个-

$s = "$434 dsvsv $567 fsdgjfb";

echo preg_replace('/\$\d+/', 'xxx', $s);
输出

xxx dsvsv xxx fsdgjfb
欢迎来到SO。请阅读,所以这不是一个免费的编码或教程服务,你必须表明你已经做出了一些努力来解决自己的问题。