JavaScript RegExp objects

前端 未结 5 1325
情话喂你
情话喂你 2020-12-07 03:51

I try to write a simple Markdown parser in JavaScript. Therefore I want to check for the [link content][link id] syntax. I use the following code:



        
5条回答
  •  难免孤独
    2020-12-07 04:27

    You need to double escape:

    var r = new RegExp( '\\[(.*?)\\][ ]*\\[([0-9]+)\\]', 'g' )
    

提交回复
热议问题