Match regex across newlines?

I have a regex ( "(<lof<).*?(>>)"

) that works great and is perfect for single line input. However, if the input contains newlines between two () parts, it does not match at all. What's the best way to ignore any newlines at all in this case?

+2
regex .net


a source to share


2 answers


Create your regex object with the parameter included RegexOptions.Singleline

:



Specifies single line mode. Modifies the value of the period (.) To match every character (instead of every character except \ n).

+4


a source to share


you can use RegexOptions.Singleline



Regex.Match(subjectString, "regex here", RegexOptions.Singleline)

      

0


a source to share







All Articles