awpti Posted February 6, 2008 Share Posted February 6, 2008 Greetings. Friend of mine created a nice REGEX to parse out specific information. The regex handles both of these strings: ------ 12/18/2007 05:43 PM 4,007,272 Win1 Name - Song Name.ext -rw------- 1 root utmp 11657088 2008-02-04 20:48 Linux Name - Song Name.ext ------ preg_match_all ( '/^.+(?:utmp|[AP]M)\s*([\d,]+)\s*(?:\d+-.+?:\d+\s*)?([\w ]+)\s+-\s+([\w ]+)\.(\w+)$/m', $input, $matches, PREG_SET_ORDER ); My problem: You can see the Output from linux has the group as 'utmp', and it appears this regex depends on that being part of it. I spent an hour or so digging through a number of regex tutorials but couldn't quite understand how to modify the regex to NOT depend on utmp being present. Unfortunately, I've got no way of contacting my friendly neighborhood regex guru. Could definately use your help, gents! Quote Link to comment Share on other sites More sharing options...
effigy Posted February 6, 2008 Share Posted February 6, 2008 (?:[AP]M|(?:utmp)?) Quote Link to comment Share on other sites More sharing options...
awpti Posted February 6, 2008 Author Share Posted February 6, 2008 Thanks a ton, effigy. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.