I have added the result in the comments after each line. I want to know why they show different results. Specially str3 and str4, which are simillar strings (in this particular context), but for str3 it shows false and for str4 it shows true. Can anyone explain why?
var regExpr = /sas/g;
var str = "sassassas";
var str1 = "sassassa";
var str2 = "safasassassas";
var str3 = "fgsassasfg";
var str4 = "fgsassassasfgdeifk";
console.log(regExpr.test(str)); //true
console.log(regExpr.test(str1)); //true
console.log(regExpr.test(str2)); //true
console.log(regExpr.test(str3)); //false
console.log(regExpr.test(str4)); //true