Cannot get regular expression work correctly with multiline

前端 未结 4 2233
南笙
南笙 2020-12-15 06:16

I have a quite big XML output from an application. I need to process it with my program and then feed it back to the original program. There are pieces in this XML which nee

4条回答
  •  旧巷少年郎
    2020-12-15 07:15

    i believe the option to use is RegexOptions.Singleline instead of RegexOptions.Multiline (src). allowing (.) to match newlines should work in your case.

    ...the mode where the dot also matches newlines is called "single-line mode". This is a bit unfortunate, because it is easy to mix up this term with "multi-line mode". Multi-line mode only affects anchors, and single-line mode only affects the dot ... When using the regex classes of the .NET framework, you activate this mode by specifying RegexOptions.Singleline, such as in Regex.Match("string", "regex", RegexOptions.Singleline).

提交回复
热议问题