正则表达式判断是否存在中文和全角字符和判断包含中文字符串长度


判断是否存在中文和全角字符

str.match(/[^\x00-\xff]/ig)

判断包含中文字符串长度
aMatch=str.match(/[^\x00-\x80]/g);

str.length+(!aMatch?0:aMatch.length)
« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3