regex to find a string that comes after =

前端 未结 6 1280
萌比男神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 07:52

    You can use this regex:

    ([^\[]*)\[[^=]+=([^\]]*)\]\[[^=]+=([^\]]*)\]
    

    You can then grap matching group #1, #2 and #3

    Live Demo: http://www.rubular.com/r/XNZfHcMAp8

    In Javascript:

    str = 'car[brand=saab][wheels=4]';
    console.log('match::' + str.match(/([^[]*)\[[^=]+=([^\]]*)\]\[[^=]+=([^\]]*)\]/));
    

提交回复
热议问题