Here is a line of Apache log:
195.239.141.56 bdnr139.valuehost.ru -
[26/Nov/2002:12:15:11 +0300] "GET / HTTP/1.1" 200 912
"http://www.somewhere.com/linkToMe.html" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
First goes IP, from where the request came, then "-" - I don't know (something unknown? or just "-"? You can read in Apache docs). then request time. Then the request itself. Then status(200) and filesize(912 bytes). Then goes the referrer (if it's empty, then it is set "-" (with quotes)). And the last is UserAgent.
then regexp like
/(.+?) (.+?) (.+?) [(.+?)] "(.+?)" (\d+) (\d+) "(.+?)" "(.+?)"/
will catch all the fields in $1 - $9 respectively.
For details look [man]preg_match()[/man].