kurbsdude Posted November 3, 2009 Share Posted November 3, 2009 ok i have an expression that could look like these id:1&user:100&age:23 or, (without the & before user) user:100&age:23 or, 1252user:100&age:23 how do i extract 'user:100' from the above expressions? thanks Quote Link to comment Share on other sites More sharing options...
salathe Posted November 3, 2009 Share Posted November 3, 2009 $subject = "1252user:100&age:23"; preg_match('/user:\d+/', $subject, $match); echo $match[0]; Quote Link to comment Share on other sites More sharing options...
kurbsdude Posted November 3, 2009 Author Share Posted November 3, 2009 thanks for the reply but i missed one thing when the expression is user:100&age:23 or 1252user:100&age:23 i want to get user:100 but when the expression is id:1&user:100&age:23 i want to get &user:100 thanks Quote Link to comment Share on other sites More sharing options...
cags Posted November 3, 2009 Share Posted November 3, 2009 That's easily fixed. $subject = "1252user:100&age:23"; preg_match('/&?user:\d+/', $subject, $match); echo $match[0]; Quote Link to comment Share on other sites More sharing options...
kurbsdude Posted November 6, 2009 Author Share Posted November 6, 2009 That's easily fixed. $subject = "1252user:100&age:23"; preg_match('/&?user:\d+/', $subject, $match); echo $match[0]; thanks a lot btw how do i mark this thread as "solved"? Quote Link to comment Share on other sites More sharing options...
nrg_alpha Posted November 6, 2009 Share Posted November 6, 2009 btw how do i mark this thread as "solved"? This is how. Quote Link to comment Share on other sites More sharing options...
cags Posted November 6, 2009 Share Posted November 6, 2009 But I don't have a button that glows red.... 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.