@writ/utils
Version:
My tool kit
12 lines (10 loc) • 353 B
JavaScript
const getPunctuationRegex = require('./cn-punctuation-regex');
/**
* 清除所有中文字符及空格(中文标点符号)
* @param {string} str
* @returns {string}
*/
function clearCNCharsAndSpaces(str) {
return str.replace(/[\u4e00-\u9fa5 ]/g, '').replace(getPunctuationRegex(), '');
}
module.exports = clearCNCharsAndSpaces;