Jump to content

[SOLVED] preg_match_all


awpti

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/89635-solved-preg_match_all/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.