【发布时间】:2013-09-24 02:43:47
【问题描述】:
我知道有很多关于同一个问题的问题。我阅读了它们,但我无法修复我的代码。
<?
$tabla = "<table>
<tr>
<td>
<a class='texto'>$ 2,123.01</a>
</td>
<td>
asddasdsad$,.$$$
</td>
</tr>
</table>";
echo preg_replace("<a class='texto'>\$ ([0-9]*),([0-9]*).([0-9]*)</a>", "<a class='texto'>$0$1,$2</a>", $tabla);
?>
PHP 错误:警告:preg_replace() [function.preg-replace]: Unknown modifier '$'
我想得到:
<?
<table>
<tr>
<td>
<a class='texto'>2123,01</a>
</td>
<td>
asddasdsad$,.$$$
</td>
</tr>
</table>
?>
我在这里http://regexpal.com/ 尝试并测试了我的正则表达式并且工作正常。但是我在 preg_replace 中有些问题。
【问题讨论】:
-
你需要
/和另一个/在正则表达式的开头和结尾 -
我试过了,但它打印了原始字符串....
标签: php regex preg-replace