regex to find a string that comes after =

前端 未结 6 1233
萌比男神i
萌比男神i 2021-01-28 07:15

I´m really new to regex and I have been looking around to find an answer but either it dont work or I get some kind of error so I will try to ask the question and hopefulyl some

6条回答
  •  面向向阳花
    2021-01-28 08:03

    you could do it with match in one shot, and get an array back.

    below lines were tested in chrome console:

    str = "car[brand=saab][wheels=4]";
    "car[brand=saab][wheels=4]"
    str.match(/[^=[\]]+(?=[[\]])/g)
    ["car", "saab", "4"]
    

提交回复
热议问题