How to use JavaScript regex over multiple lines?

前端 未结 6 1057
情歌与酒
情歌与酒 2020-11-22 04:04
var ss= \"
aaaa\\nbbb\\nccc
ffffd\"; var arr= ss.match( //gm ); alert(arr); // null

I\'d want the PR

6条回答
  •  天命终不由人
    2020-11-22 04:56

    I have tested it (Chrome) and it working for me( both [^] and [^\0]), by changing the dot (.) by either [^\0] or [^] , because dot doesn't match line break (See here: http://www.regular-expressions.info/dot.html).

    var ss= "
    aaaa\nbbb\nccc
    ffffd"; var arr= ss.match( //gm ); alert(arr); //Working

提交回复
热议问题