preg_replace模式为英寸替换PHP与词边界

时间:2011-05-28 10:54:27

标签: php regex

我想替换像:

Remo Suede Emperor Drumhead 12" or
Remo Suede Emperor 12" Drumhead

Remo Suede Emperor Drumhead 12inch or
Remo Suede Emperor 12inch Drumhead

您知道哪种模式最适合preg_replace功能吗?

P.S。在那里也有一个词边界是好的,以避免错误的positivies replacamenet即。

123M90"

1 个答案:

答案 0 :(得分:3)

$string = preg_replace('/([0-9])"/', '$1inch', $string);