regex to find a string that comes after =

前端 未结 6 1311
萌比男神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:54

    /([^\[]+)\[brand=([^\]]+)\]\[wheels=(\d)\]/
    

    Works.

    Try it like

    var result = "car[brand=saab][wheels=4]".match(/([^\[]+)\[brand=([^\]]+)\]\[wheels=(\d)\]/)
    

    Result would be

    [ "car[brand=saab][wheels=4]", "car", "saab", "4" ]
    

提交回复
热议问题