Home  >  Article  >  php教程  >  正则替换全角字符

正则替换全角字符

PHP中文网
PHP中文网Original
2016-05-25 17:13:441405browse

php代码

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

Statement:
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