如何代替……一个单词的一部分是数字,另一部分是'int


how to replace ... between a word where one part is numeric the other is'int?

如何在一个部分是数字而另一部分是int的单词之间放置空格?像这样:

$string = "this is a 2000px height photo";
$string = preg_replace('???',' //1',$string);
echo $string; //this is a 2000 px height photo

有人能帮帮我吗?谢谢!

$string = preg_replace('/('d+)([[:alpha:]]+)/', '$1 $2', $string);
  • 'd+匹配任意数字
  • [[:alpha:]]+匹配任何字母('w+是错误的,因为匹配字母和数字: preg_replace()呼叫拆分数字-例如:'100'变成'100')