Javascript array string to regex literal

后端 未结 2 648
北海茫月
北海茫月 2021-01-21 20:13

I have a working example here: http://jsfiddle.net/R7KuK/

I\'ve tried to create an array containing full regular expressions with regex delimiters and set flags, but the

2条回答
  •  不思量自难忘°
    2021-01-21 20:13

    as stolen from here:

    Use the RegExp object constructor to create a regular expression from a string:

    var re = new RegExp("a|b", "i");
    // same as
    var re = /a|b/i;
    

提交回复
热议问题