moola Posted March 29, 2007 Share Posted March 29, 2007 http://s64.photobucket.com/albums/h162/Chuckie82892/?action=view¤t=Shannon411.flv How do you match h162 (letter number number number) *variable and Chuckie82892 (username) *variable and Shannon411.flv (videoname) *variable Thanks Link to comment https://forums.phpfreaks.com/topic/44723-matching-stuff-from-url/ Share on other sites More sharing options...
c4onastick Posted March 30, 2007 Share Posted March 30, 2007 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¤t=Shannon411.flv', 'h162', 'Chuckie82892', 'Shannon411.flv' ) Link to comment https://forums.phpfreaks.com/topic/44723-matching-stuff-from-url/#findComment-217893 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.