From: "Sorry Confidential" <[EMAIL PROTECTED]>

> I'm trying to parse a Postfix queue file to extract a few informations.
The
> Postfix queue file is a binary file.
>
> Here is an extract of the file, not a line, just an extract:
> N^WFrom: <[EMAIL PROTECTED]>N^[To: <[EMAIL PROTECTED]>N#Subject: Test 14
> 2004-04-13  15:13N%Date: Tue, 13 Apr 2004 15:13:35 -0400
>
> $line is obtained with an fread
>
> if (preg_match('/To:.<(.+)>/',$line,$match)){
>   print "To= $match[1]";
> }
>
> I get:
> To= <[EMAIL PROTECTED]>N#Subject: Test 14  2004-04-13  15:13N%Date: Tue, 13
> Apr 2004 15:13:35 -0400
>
> I was expecting:
> To= [EMAIL PROTECTED]

Try preg_match('/To:.<([^>]+)>/',$line,$match)

Also, if you need to match more than one "to" at a time, look at
preg_match_all(). Depending on the size of the file, it may be more
efficient to read the entire file and match all of these at once.

---John Holmes...

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to