I am attempting to extract strings that are located between two specific strings, but the output I am getting from using str.match is not what I anticipated:
var text = "first second1 third\nfirst second2 third\nfirst second3 third";
var middles = text.match(/first (.*?) third/g);
console.log(middles); //this should be ["second1", "second2", "second3"]
However, the actual result looks like this:
["first second1 third", "first second2 third", "first second3 third"]
Is there a different approach I can take to only extract the middle strings for each occurrence?