Why this regex isnt working?

limitless

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 ?

Scott Weaver

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

why isnt this padding working?

From Dev

Why this code isnt working?

From Dev

Why isnt ActionListener working?

From Dev

Why .hasClass function isnt working?

From Dev

Why isnt Gesture Listener working?

From Dev

Why isnt this simple inheritance working?

From Dev

Why isnt my middleware working?

From Dev

Why my code isnt working?

From Dev

Why isnt my Background color working in a ComboBox

From Dev

Why isnt my foreach loop working?

From Dev

Why isnt the move method working in Java?

From Dev

install google-chrome isnt working, why?

From Dev

Why isnt my update from client working?

From Dev

Why isnt collapse from bootstrap working?

From Dev

Why isnt my Background color working in a ComboBox

From Dev

Why isnt this working? ZXing, Bitmap, ImageSource

From Java

why isnt my regex matching the below numerical strings?

From Dev

I can't figure out why my clearfix isnt working

From Dev

Why isnt df["ColumA"] = df_2["ColumnB"] working as expected?

From Dev

Is there a reason why my clearInterval function isnt working in React?

From Dev

I can't figure out why my clearfix isnt working

From Dev

Why isnt my nested ng-repeat working

From Dev

Why isnt this merge sort on linked list working properly?

From Dev

not sure why my looping function isnt working here

From Dev

Why isnt Bootstrap Grid working properly after my main header?

From Dev

Would like to understand why this "setInterval" in my code isnt working?

From Dev

JQuery insertBefore() isnt working

From Dev

addClass() isnt working

From Dev

HTML Mandarin isnt working