$re = '/(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)))?$/m';
$str = '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
';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
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 PHP, please visit: http://php.net/manual/en/ref.pcre.php