Home > php教程 > PHP源码 > body text

正则替换全角字符

PHP中文网
Release: 2016-05-25 17:13:44
Original
1441 people have browsed it

php代码

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

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template