0

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 [email protected]", "some + text [email protected]", "another + text [email protected]", "text + text [email protected]");
  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: [email protected]
match: null
match: [email protected]
match: null

Kintaro
  • 178
  • 3
  • 14

0 Answers0