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... Link to comment https://forums.phpfreaks.com/topic/44316-help-me-new-to-regex/ 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.. Link to comment https://forums.phpfreaks.com/topic/44316-help-me-new-to-regex/#findComment-215227 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> Link to comment https://forums.phpfreaks.com/topic/44316-help-me-new-to-regex/#findComment-215364 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.