1
我在PHP中的文本字符串:的preg_replace变化括号和文本
$str = 'This is a simple \^{text}. It does not look well \_{styled}.';
我想要做的是改变“\^{文字}”和“_ {样式}”使用的preg_replace得到这样
$str = 'This is a simple <sup>text<sup>. It does not look well <sub>styled</sub>.';
HTML代码,我现在这样做是:
function Translate($str)
{
return preg_replace('/\\\\\^\{.*\}/i', '<sup>$1</sup>', $str);
}
echo Translate("this offer starts at \^{abc}");
这并不正确以$ 1的工作!在$ 0整个比赛是正确的... 有人可以帮助我吗? Regars!