将手机号倒数4/5位替换为星号,php的测试用例是这样
<?php
$string = “138265895493”;
$pattern = “/(1d{1,5})dd(d{3,4})/”;
$replacement = “$1**$2″;
print preg_replace($pattern, $replacement, $string);
?>
在smarty中是用regex_replace函数,它参数的写法和php里的preg_replace一样的,可以这样写
<{$sellLogListData.name|regex_replace:”/(1d{1,5})dd(d{3,4})/”:”$1**$2″}>