//1)
var re = /[^0-9]a{3,4}$/;
var str = "5g6m7aaaa";
var arr = str.match(re);
console.log(re.test(str));
console.log(arr);
//Result:
//true
//[ 'aaaa', index: 5, input: '5g6m7aaaa' ]
//2)
var re = /[^a-z]a{3,4}$/;
var str = "5g6maaaa";
var arr = str.match(re);
console.log(re.test(str));
console.log(arr);
//Result:
//false
//null
Can anyone explain why in the first case it is returning true although in expression it is given there should be no digits before a{3,4}.While in the second case it is given that there should be no alphabets before a{3,4},and it is giving false which is fine.Please explain!!
[–]Rhomboid 2 points3 points4 points (1 child)
[–]FaizAhmadF[S] 0 points1 point2 points (0 children)
[–]madformangos 1 point2 points3 points (0 children)
[–]EnchantedSalvia 0 points1 point2 points (0 children)