Hi,

I have text file which has lots of text as well as HTML data. There are some line as shown below.

06/30/12 00:40:30.73 Sending Email - Group: 4FD7917824F1B-EMAIL, 0, Message: 

There are lots of lines like above in text file. I want to extract following data from the entire text file.

Group: 4FD7917824F1B-EMAIL

I know this can be done by regular expression but I don't know how exactly done it. Some one can please provide some regular expression for above or some explanation.

Member Avatar
diafol

I'm crap at regex, but you could try something like this:

$str = "06/30/12 00:40:30.73 Sending Email - Group: 4FD7917824F1B-EMAIL, 0, Message:";
preg_match("/Sending Email - ([^,]*),/",$str,$matches);
echo $matches[0];

Or even:

$cut = explode(' - ',$str);
$detail = explode(',',$cut[1]);
echo $detail[0];