View Single Post
Old 06-19-2008, 10:20 PM   #2 (permalink)
Wildhoney
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

The only problem I see with my code is if a square bracket appears in the error description somewhere. If not then it will work fine. If, however, it does appear in the description, I'm not sure a way around it. You could possibly narrow it down by checking if the square bracket is at the beginning of a new line.

PHP Code:
$szSamba = <<<TP

[2008/04/10 08:09:44, 0] lib/util_sock.c:get_peer_addr(1229)
getpeername failed. Error was Transport endpoint is not connected
[2008/04/30 11:51:36, 0] smbd/server.c:main(847)
smbd version 3.0.23d-6-1083-SUSE-SL10.2 started.
Copyright Andrew Tridgell and the Samba Team 1992-2006
[2008/04/10 08:09:44, 0] lib/util_sock.c:get_peer_addr(1229)
getpeername failed. Error was Transport endpoint is not connected
[2008/04/30 11:51:36, 0] smbd/server.c:main(847)
smbd version 3.0.23d-6-1083-SUSE-SL10.2 started.
Copyright Andrew Tridgell and the Samba Team 1992-2006

TP;

preg_match_all('~\[(.+?)\]([^\[]+)~ix'$szSamba$aMatches);
print_r($aMatches); 
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
The Following User Says Thank You to Wildhoney For This Useful Post:
quantumkangaroo (06-20-2008)