IF THE FARE COMPONENT INCLUDES TRAVEL BETWEEN HND AIRPORT
AND SEL
ON DIRECT FLIGHTS
OUTBOUND -
PERMITTED 201PM TO MIDNIGHT DAILY ON THE FIRST
INTERNATIONAL SECTOR.
INBOUND -
PERMITTED 1201AM TO 200PM DAILY DEPARTURE OF LAST
INTERNATIONAL SECTOR.
OTHERWISE
PERMITTED 1201AM TO MIDNIGHT DAILY.
我想分成两组
A:
IF THE FARE COMPONENT INCLUDES TRAVEL BETWEEN HND AIRPORT
AND SEL
ON DIRECT FLIGHTS
OUTBOUND -
PERMITTED 201PM TO MIDNIGHT DAILY ON THE FIRST
INTERNATIONAL SECTOR.
INBOUND -
PERMITTED 1201AM TO 200PM DAILY DEPARTURE OF LAST
INTERNATIONAL SECTOR.
B:
PERMITTED 1201AM TO MIDNIGHT DAILY.
这样的正则,解析不出来。
(?<A>\s+.*)\sOTHERWISE(?<B>\s+.*)
------解决思路----------------------
static void RegexChinese()
{
string txt = @"IF THE FARE COMPONENT INCLUDES TRAVEL BETWEEN HND AIRPORT
AND SEL
ON DIRECT FLIGHTS
OUTBOUND -
PERMITTED 201PM TO MIDNIGHT DAILY ON THE FIRST
INTERNATIONAL SECTOR.
INBOUND -
PERMITTED 1201AM TO 200PM DAILY DEPARTURE OF LAST
INTERNATIONAL SECTOR.
OTHERWISE
PERMITTED 1201AM TO MIDNIGHT DAILY.";
var match = Regex.Match(txt, @"(?<A>[\s\S]*)OTHERWISE(?<B>[\s\S]*)");
if (match.Success)
{
Console.WriteLine("A:" + match.Groups["A"].Value);
Console.WriteLine("=============================");
Console.WriteLine("b:" + match.Groups["B"].Value);
}
}