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 Link to comment https://forums.phpfreaks.com/topic/149449-solved-php-function-preg_replace-help-please/ 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 ~-[^-]*-~ Link to comment https://forums.phpfreaks.com/topic/149449-solved-php-function-preg_replace-help-please/#findComment-784930 Share on other sites More sharing options...
coder330 Posted March 15, 2009 Author Share Posted March 15, 2009 it works! thanks a lot! Link to comment https://forums.phpfreaks.com/topic/149449-solved-php-function-preg_replace-help-please/#findComment-784979 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.