正则

匹配除中文、空格以外的其他所有字符

1
2
3
4
5
6
7
8
9
10
11
// 先校验空格,再校验非中文
var line = 'aa bb cc'
if (line.trim().split(/\s+/).length > 2)
...
...
function validateLine (line){
// var checkKaMi=/^[A-Za-z0-9_]+[\s]+[A-Za-z0-9_]+$/;
// 非中文以外的所有其他字符
var checkKaMi=/^[^\u4e00-\u9fa5]+[\s]+[^\u4e00-\u9fa5]+$/;
return checkKaMi.test(line);
}

Powered by Hexo and Hexo-theme-hiker

Copyright © 2013 - 2024 HL's Blog All Rights Reserved.

UV : | PV :