Answer the question
In order to leave comments, you need to log in
Why doesn't RegExp take into account line breaks?
I wrote a regular expression new RegExp('(<%--)(.*)(--%>)','gim') , which should find everything that is enclosed in the character sequence <%-- --%> . Within a single line, this works fine, but if there is a line break between the <%-- --%> character sequences , then everything will break. I decided to catch the line break with this regular expression: (<%--)([\s\S]*)(--%>), but it does not work correctly.
Tell me how to write a regular expression that will take into account line breaks?
Answer the question
In order to leave comments, you need to log in
Decimal point denotes any character except newlinejavascript.ru/regexp
/(<%--)((?:.|\n)*)(--%>)/gmi
.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question