My question is very simple. Thank God because Regex's can be complex...
I have a query parameter in the url, given by ?id=0061ecp6cf0q
.
I would like to match it, but only capture the part after the equals sign.
I have a regex as such:
(?:\?id=){1}([a-z0-9])+
When, in JavaScript, I have a string containing the query parameter and do a .match() on it with a regular expression object constructed from the regex above, I am returned an array of length 1 with the entry: "?id=0061ecp6cf0q".
When I do a .exec() on the regex with the query string as a parameter, I am returned an array of length 2:
array[0] = "?id=0061ecp6cf0q"
array[1] = "q"
1) Why is my non-capturing group seemingly capturing? 2) Why is "q" being captured, of all things?