On 11 April 2011 13:23, Stuart Dallas <stuart@xxxxxxxx> wrote: > On Monday, 11 April 2011 at 13:17, Curtis Maurand wrote: > Stuart Dallas wrote: >> > On Monday, 11 April 2011 at 02:12, Curtis Maurand wrote: >> > nevermind. There is a function: fgetcsv(); >> > >> > Ewww! >> >> Say what you want, it works. Your solution is way more elegant. regex's are not my strong suit. I have to have the regex pocket reference to understand that regex that's in there. However, the fgetcsv breaks it up into a few chunks and I have to break up the first chunk, but that's space delimited, so its not so bad. I'll probably use yours. Thanks for the class. > > I'm not a great regex guru either, I googled that - it's not my class. > > You can use a hammer to knock in a screw, but when screwdrivers are ubiquitously lying around all over the internet, why would you?! > > -Stuart > > -- > Stuart Dallas > 3ft9 Ltd > http://3ft9.com/ > > >> > >> > http://blog.ericlamb.net/2010/01/parse-apache-log-files-with-php/ >> > >> > -Stuart >> > >> > -- >> > Stuart Dallas >> > 3ft9 Ltd >> > http://3ft9.com/ >> > >> > >> > > Curtis Maurand wrote: >> > > > >> > > > >> > > > Hello, >> > > > I'm trying to run through an apache log >> > > file in an attempt to >> > > > get all of the user agents. >> > > > >> > > > The question is how do I split the >> > > > string? I can't >> > > seem to find a workable delimiter. Each >> > > > section of the >> > > file is enclosed in quotes and that should be helpful, but >> > > > it >> > > doesn't seem to be. I can't seem to set the delimiter to '" >> > > "' I can't >> > > > seem to find any good >> > > > examples, >> > > either. >> > > > >> > > > I can't split on spaces, because the user >> > > > agents generally have spaces in them. >> > > > >> > > > I was >> > > trying to use >> > > > explode. >> > > print_r(explode('" "', $line); >> > > > >> > > > Any help >> > > > would be appreciated. >> > > > thanks, >> > > > Curtis >> > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > Certain data sequences (especially like the Apache log file), are well documented and as such, due to their regular format, are sometimes easier to read using a regex than by manually pulling apart using string functions. I use an app called RegexBuddy (it's a windows app) which is really useful for describing a regex string in human readable format. I can recommend http://www.regular-expressions.info, http://www.regexbuddy.com and http://www.regular-expressions.info/cookbook.html I am not affiliated with any of these sites/books, just a happy customer. -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php