Jump to content

matching stuff from url


moola

Recommended Posts

You match 'h162' with:

%[a-z]\d{3}%

Or more generally:

%[a-z]\d+%

(% is my delimiter)

 

'Chuckie82892' is tougher, you have to assume that it is always between '/' and '/?' to match it. You could use this:

%[a-zA-Z]{2,}\d+%

But that will also match 'Shannon411.flv'. (Works in this case since Chuckie comes first)

 

Matching 'Shannon411.flv' is easy, just assuming that whatever comes after 'current=' is what you want:

%current=(.*)%

 

To get these all individually would be a pain and pointless really since you can do it all in one foul swoop:

preg_match('%albums/([^/]+)/([^/]+)/\?.*?current=(.*)%', $url, $matches);

 

$matches contains:

Array( 'albums/h162/Chuckie82892/?action=view&current=Shannon411.flv',
       'h162',
       'Chuckie82892',
       'Shannon411.flv' )

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.