using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"^(\s*(?:Su|M|Tu|W|Th|F|S|R))((?:Su|M|Tu|W|Th|F|S|R){1,2})(.*)";
string substitution = @"$1$3\n$2$3";
string input = @"WRF 9a-5p
WR 9-10:15a
WR 7:15-8:45p
WF 9a-12:10p
WF 9:30-11:30a
WF 8-10:45a
WF 12-2:45p
Su 9a-6p
WF 10-11:50a
W 9a-12p
W 9a-12p
W 9a-12:20p
W 9a-12:20p
W 9a-12:20p
W 9:30a-4:45p";
RegexOptions options = RegexOptions.Multiline;
Regex regex = new Regex(pattern, options);
string result = regex.Replace(input, substitution);
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx