【问题标题】:Preg_replace on html and diacriticsPreg_replace 关于 html 和变音符号
【发布时间】:2013-07-01 10:26:58
【问题描述】:

有没有办法做 preg_replace :

<p style="background:white">
<span style="font-size:10.0pt;font-family:&quot;Trebuchet MS&quot;,&quot;sans-serif&quot;">
Coût de la prestation : 43.19 . <u></u><u></u></span></p>

我只想删除或留有空格的价格。我不知道如何定义模式和替换表达式。

希望有人帮助我!

TY.

编辑:我只想删除 43.19 .,只是 Coût de la prestation:

【问题讨论】:

  • 您能否澄清一下您要做什么(“我只想删除或留下空格”)?

标签: php html preg-replace diacritics


【解决方案1】:

你试过u modifier吗?

类似:

preg_replace('/Coût de la prestation : (\d+\.\d{2})/u', 'whatever', $str);

【讨论】:

    【解决方案2】:

    最后起作用的是:

    preg_replace('#(Coût\s+de\s+la\s+prestation)\s*:\s*\d+(\.\d+)?#u', '$1:', $body);
    

    谢谢大家。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-03-24
      • 2010-10-23
      • 2016-01-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多