drbigfresh Posted April 15, 2007 Share Posted April 15, 2007 I don't know why I even bother with Regex...way above my head. I am trying to extract some data from a url, and am not having much luck with it. The URLs are in this format (with no trailing slash at the very end and no defined length for the username or IDNumber): 'http://domain.com/[username]/updates/[iDNumber]' e.g. 'http://domain.com/drbigfresh/updates/546872' Is there anyway to regex the username and IDNumber out into two separate variable? Thanks, Scott. Quote Link to comment Share on other sites More sharing options...
c4onastick Posted April 15, 2007 Share Posted April 15, 2007 Yep. Here's how I'd go about this: preg_match('%\.com/([^/]+)/updates/(\d+)%', $text, $matches); $matches is an array containing the entire match, username, and ID. Cheers! 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.