I'm trying to come out with a regulat expression to extract the value of a querystring parameter
so far now I came with the following:
app.getValue = function() {
var regExp = '[&?]'+$("#token").val()+'=(.*?)[&$]';
var re = new RegExp(regExp);
var res = re.exec($("#url").val());
if (!res) return '';
return res[1] || '';
}
the problem seems to be that the "$" in the end of the resultar expression is being interepreted as a literal character, and not as the end of the input string
so with the followgin querystring:
http://wines?len=10&page=500&filter=bogota and salvador&sort=name asc
looking for the token "sort" doesn't get me anything, if I add a "&" or a "$" at the end of the string it works...
Am I missing something?