coder330 Posted March 15, 2009 Share Posted March 15, 2009 Hi , i am having a really hard time with preg_replace...it would be great if someone can help me out. so lets say i have a string "aabdbs-565-djdjdhjj990.fhfh4" I only want the numbers between -'s...so i only want either "-565-" or "565" anyone know how to use preg_replace to get that? thank you Quote Link to comment Share on other sites More sharing options...
.josh Posted March 15, 2009 Share Posted March 15, 2009 preg_replace is used to replace one thing with another. If you want to capture stuff, use preg_match or preg_match all. Your pattern would be ~-[^-]*-~ Quote Link to comment Share on other sites More sharing options...
coder330 Posted March 15, 2009 Author Share Posted March 15, 2009 it works! thanks a lot! 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.