If I have a regex with multiple matches like:
var matches = string.match(/\s*(regex1)?\s*(regex2)?(regex3)?\s*/i);
and if the string I'm testing looks like this:
var string = "regex1 regex3";
Is there a way to capture these values in an array:
matches[1] = "regex1";
matches[2] = "";
matches[3] = "regex3";
Note: I want the regex to match the entire string, but fill the array with placeholders for any matches it doesn't find.
Hopefully that's clear. Thank you for your assistance!