Im trying to split cookies into gropus using this regex (.*?=.*?); ?
What i meant to get is a cookie in each regex group. But it's only giving me the first group that match.
var string = userid=edaa4200-b140-47fd-9db8-b48082a0d0a8; ab_93896527=0;
edit : I'm using exec()
function
var cookies_tuples = /(.*?=.*?); ?/g.exec(string);
what could be the problem ?
you have to call exec
multiple times, even with the global flag enabled:
var re = /(.*?=.*?);\s?/g;
var input = "userid=edaa4200-b140-47fd-9db8-b48082a0d0a8; ab_93896527=0;";
var myArray;
while ((myArray = re.exec(input)) != null)
{
var msg = "Found " + myArray[0];
console.log(msg);
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments