regexp我尝试过include(对于大写)。以下返回true
self.upperCharCheck = false ; //has to be false by default
var temp ="(?=(.*[^A-Z]))";
self.testUpperCase = new RegExp(temp);
self.upperCharCheck = (self.testUpperCase.test(self.newPassword));
如果没有UpperCase,我希望self.upperCharCheck为true,否则如果存在大写则为false。
答案 0 :(得分:3)
/[A-Z0-9]/
应该是检查字符串是否包含大写字母或数字所需的全部内容:
var upperRegex = /[A-Z0-9]/;
console.log(upperRegex.test('should be false'));
console.log(upperRegex.test('should be True'));
console.log(upperRegex.test('should also 0 be true'));
console.log('===');
//This will return false if an uppercase letter or a number is in the string
var upperRegex2 = /^[^A-Z0-9]+$/;
console.log(upperRegex2.test('should be true'));
console.log(upperRegex2.test('should be False'));
console.log(upperRegex2.test('should also 0 be false'));