Given the following two examples:
'123?type=hand' ===> 'type'
'123?type=hand&status=alive' ===> 'type status'
In english I want: Find the ? and remove everything in front.
Find = and remove everything after it until the &.
In the end of the day what I want is just either a string, array, whatever of the actual queryStringVariableNames. Not any of the values.
I think I'm over complexifying it. :)
Here is a couple snippets I have been working with:
var pattern = /\*(\?)|\*(\&)|(\=)\*/ig;
var pattern = /(.+?\?)/g;
str.replace(pattern, function (matcher, positionOfMatch, item) {
return '';
});
I started using the longform of replace so I could see better what was going on.
EDIT
My exact implementation ended up being the following:
function (str) {
str = str.substr(str.indexOf('?') + 1);
return str.split('&')
.map(function (i) {
return i.substr(0, i.indexOf('='))
});
}