My PHP code is:
$pattern = '/(Sun|Mon|Tue|Wed|Thu|Fri|Sat)(,| )[\d]{1,2}[A-Z]{1,1}[a-z]{2,2}/';
if (preg_match($pattern, $content, $matches, PREG_OFFSET_CAPTURE)){
$name = str_replace("(M1) ", "", substr($content, 0, $matches[0][1]));
$date = substr($content, $matches[0][1], 15);
}
It works fine with one match sub pattern.Like:
B'Meadow Alarm Tue,17Sep 19:48 Ur001 General User Closing By User name: B'Meadow Alarm date: Tue,17Sep 19:48
My string is:
(M1) B'Meadow Alarm Tue,17Sep 19:48 Ur001 General User Closing By User (M2) B'Meadow Alarm Tue,18Nov 09:18 Ur001 General User Closing By User
it is supposed to be:
name: B'Meadow Alarm date: Tue,17Sep 19:48
But the reality result is:
name: B'Meadow Alarm Tue,17Sep 19:48 Ur001 General User Closing By User (M2) B'Meadow Alarm date: Tue,18Nov 09:18
Question: What is wrong in my pattern? or code?
----------
Edit
Sorry, guys! One of my colleague changed this regular expression on Server's repository to following one:
'/(.*)(Sun|Mon|Tue|Wed|Thu|Fri|Sat)(,| )[\d]{1,2}[A-Z]{1,1}[a-z]{2,2}(.*)/';
But he doesn't commit to git. That is why I can't see these changes in my local repository. the (.*) cause the problem.