0

Ususually you get your matches somewhat like this:

var myString = "Hello Alex, I am John";
matches = myString.match(/"Hello (.+) I am (.+)/);
console.log(match[1]);
console.log(match[2]);

But is it possible in javscirpt to name your matches within the regex?

Somewhat like this:

var myString = "Hello Alex, I am John";
matches = myString.match(/"Hello ([hisName].+) I am ([yourName].+)/);
console.log(match.hisName);
console.log(match.yourName);
Forivin
  • 13,544
  • 25
  • 91
  • 183

0 Answers0