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' )

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.