首页 > PHP > PHP使用正则替换全角字符的函数

PHP使用正则替换全角字符的函数

function zo_replace(text) {
return text && text.replace(/[\u3000\uff01-\uff5f]/g, function($0) {
return $0 == “\u3000″ ? ” ” : String.fromCharCode($0.charCodeAt(0) – 0xfee0);
});
}

分类:PHP 标签:, , ,
  1. 还没有评论。
  1. No trackbacks yet.

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s

%d 博主赞过: