How to use JavaScript regex over multiple lines?

前端 未结 6 933
情歌与酒
情歌与酒 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:42

    [.\n] doesn't work, because dot in [] (by regex definition; not javascript only) means the dot-character. You can use (.|\n) (or (.|[\n\r])) instead.

提交回复
热议问题