简体   繁体   中英

Multiline regex not matching

I'm trying to get a multi-line regex working with .NET but not having much luck. I believe I'm right in thinking that this will match multiple lines, but the third match is always omitted. I need to capture the recipient and reason fields. I know I could do this with a loop and two regexes but I'd prefer a more succinct solution.

The regex I'm using is:

(.*?)Destination: mobile (\(SMS\))?(\d{10,})(?:.*?)Reason: (.*)

It should match against this text:

NON-DELIVERY NOTE

The following message was not delivered:

Addressed to: 01234567890@sms.local
Destination: mobile (SMS)01234567890
Reference number: 155618127W

Reason: Rejected by network operator

在这种情况下,您需要使用RegexOptions.Singleline而不是RegexOptions.Multiline

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM