I can't understand why is skipping 2nd and 4th array position giving to the variable match a "null" value.
// regex to catch email
var regExp = new RegExp("[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,6}", "gi");
var emailArray = Array("foo + bar tes+T@gmail.com", "some + text test2A@gms.com", "another + text test3+d@dddd.com", "text + text testtest4@ggg.com");
for (var h = 0; h < emailArray.length; h++){
Logger.log("The value was: " + emailArray[h]);
var match = regExp.exec(emailArray[h]);
Logger.log("I found: " + match);
}
Results:
match: tes+T@gmail.com
match: null
match: test3+d@dddd.com
match: null