how to use dotall flag for regex.exec()

后端 未结 4 868
我寻月下人不归
我寻月下人不归 2020-11-30 11:34

i want get to string in a multiline string that content any specific character and i want get to between two specific staring.

i used this regex and this work but if

4条回答
  •  孤城傲影
    2020-11-30 11:59

    Use catch all character class [\s\S] which means space or non space

    var regex = new RegExp("\-{2}Head([\s\S]*)-{2}\/\Head","m");      
    var content = "--Head \n any Code \n and String --/Head";
    var match = regex.exec(content);
    

提交回复
热议问题