const string input = "===== Action: [Action1] State: [State1] by:[user1] at [timestamp1] ===== [Notes1]===== Action: [Action2] State: [State2] by:[user2] at [timestamp2] ===== [Notes2]";
Regex expression = new Regex(@"===== Action: (?<Action>.*?)State:(?<State>.*?)by:(?<userid>.*?)at(?<timestamp>.*?)=====(?<Note>.*?)");
var results = expression.Matches(input);
foreach (Match match in results)
{
Console.WriteLine("UserId:" + match.Groups["userid"].Value);
Console.WriteLine("Action:" + match.Groups["Action"].Value);
Console.WriteLine("State:" + match.Groups["State"].Value);
Console.WriteLine("TimeStamp:" + match.Groups["timestamp"].Value);
Console.WriteLine("Note:" + match.Groups["Note"].Value);
}
我能够正确解析除 Note 之外的所有值。任何想法我做错了什么?