龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > php编程 >

php 正则表达式替换字符串中的全角字符

时间:2014-06-19 02:16来源:网络整理 作者:网络 点击:
分享到:
正则表达式替换字符串中的全角字符 如下代码替换全角字符:```{php}function zo_replace(text) { return text amp;amp; text.replace(/[\u3000\uff01-\uff5f]/g, function($0) { return $0 == quot;\u3000quot; ? quot; quot; : St

如下代码替换全角字符:

function zo_replace(text) {
    return text && text.replace(/[\u3000\uff01-\uff5f]/g, function($0) {
        return $0 == "\u3000" ? " " : String.fromCharCode($0.charCodeAt(0) - 0xfee0);
    });
}
精彩图集

赞助商链接