0
我有这个代码片段从旧自从安装标点符号ereg_replace的preg_replace
$pattern = $this->attributes['SEO_REMOVE_ALL_SPEC_CHARS'] == 'true'
? "([^[:alnum:]])+"
: "([[:punct:]])+";
我想修改[:PUNCT:]选择,因此排除了 - 冲刺。的代码
下一行是
$anchor = ereg_replace($pattern, '', strtolower($string));
其去除先前发现的字符。我怎样才能保持我的破折号?
感谢,马里奥
编辑
我觉得我得到它:
$pattern = $this->attributes['SEO_REMOVE_ALL_SPEC_CHARS'] == 'true'
? "([^[:alnum:]])+"
: "([^-a-zA-Z0-9[:space:]])+";
注:破折号必须是第一位的。或者,对于下划线:
$pattern = $this->attributes['SEO_REMOVE_ALL_SPEC_CHARS'] == 'true'
? "([^[:alnum:]])+"
: "([^a-zA-Z0-9_[:space:]])+";
我也没弄明白怎么用负向前看符号:( 干杯马里奥