Regular expression to get number between two square brackets

前端 未结 6 1674
死守一世寂寞
死守一世寂寞 2021-01-27 14:19

Hi I need to get a string inside 2 pair of square brackets in javascript using regular expressions.

here is my string [[12]],23,asd

So far what I tr

6条回答
  •  无人及你
    2021-01-27 14:27

    I've only done it with 2 regExps, haven't found the way to do it with one:

    var matches = '[[12]],23,asd'.match(/\[{2}(\d+)\]{2}/ig),
        intStr = matches[0].match(/\d+/ig);
    
    console.log(intStr);
    

提交回复
热议问题