preg_match in JavaScript?

后端 未结 8 1930
逝去的感伤
逝去的感伤 2020-12-08 13:17

Is it possible in JavaScript to do something like preg_match does in PHP ?

I would like to be able to get two numbers from str

8条回答
  •  借酒劲吻你
    2020-12-08 13:50

    This should work:

    var matches = text.match(/\[(\d+)\][(\d+)\]/);
    var productId = matches[1];
    var shopId = matches[2];
    

提交回复
热议问题