using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"(t(?:h[uứ])? ?(?:tư|[2-7]|hai|ba|năm|sáu|bảy)|chủ nhật)( *)(?: ?(?:đầu|cuối)? ?(?:tuần (?:trước|sau|này)))?$";
string input = @"thứ 2
thứ 3
thứ 4
thứ 5
thứ 6
thứ 7
t2
t3
t4
t5
t6
t7
thứ hai
thứ ba
thứ tư
thứ2
thứ3
chủnhật
Chủ nhật
thứ hai cuối tuần sau
thứ ba cuối tuần sau
thứ tư cuối tuần sau
thứ năm cuối tuần sau
thứ năm đầu tuần sau
thứ sáu đầu tuần sau
thứ bảy tuần sau
chủ nhật tuần trước
chủ nhật tuần này
t8 cuối tuần này
thuhai
thuba
thutu
thunam
tha thu
";
RegexOptions options = RegexOptions.Multiline;
foreach (Match m in Regex.Matches(input, pattern, options))
{
Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index);
}
}
}
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