DanDaBeginner Posted March 26, 2007 Share Posted March 26, 2007 please patient with my codes i am totally new when it comes to regex.. i got this code.. <?php $str = '/mem/P/ers/none/x/vV7yiWQN21v6zoHR/9xx33'; $patt = '/[a-zA-Z0-9]{3}/[a-zA-Z0-9]/[a-zA-Z0-9]{3}\/[a-zA-Z0-9]{4}/[a-zA-Z0-9]{16}/'; echo preg_replace($patt,"",$str); ?> I need to cut this url: "/mem/P/ers/none/x/vV7yiWQN21v6zoHR/"--> remove this, "9xx33" get this one: but its not getting the data the worst is, it cuts nothing..im very sure that the error was in my regex.. please help.. thanx in advance... Quote Link to comment Share on other sites More sharing options...
DanDaBeginner Posted March 26, 2007 Author Share Posted March 26, 2007 the modify button is missing so I posted a new one.. sowee! I know I can chop this simply by using explode.. but I want to learn regex.. Quote Link to comment Share on other sites More sharing options...
effigy Posted March 26, 2007 Share Posted March 26, 2007 <pre> <?php echo $str = '/mem/P/ers/none/x/vV7yiWQN21v6zoHR/9xx33'; echo '<br>'; echo preg_replace('%(.+)/.+\z%', '\1', $str); ?> </pre> 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.