On Fri, 6 Mar 2009 21:32:53 +0200, Nitsan Bin-Nun wrote: > Hi lista, > > I have been trying to figure this out for the last couple of hours but I'm > lack of luck. > Take a look at these regex's, the string that was inputed into the > preg_replace (using Uis modificators) and the results: > (the lists have correspondence to each other) > > ORIGINAL STRING > ---- > http://www.zshare.net/video/541070871c7a8d9c > > REGEX USED (with Uis modificators) > ---- > http:\/\/(www\.|)zshare\.net\/video\/([^\/]+) $3 > > THE RETURNED STRING > ---- > 41070871c7a8d9c Is this what you're doing? echo preg_replace('/http:\/\/(www\.|)zshare\.net\/video\/([^\/]+)/Uis', '', 'http://www.zshare.net/video/541070871c7a8d9c'); echo "\n"; The "U" modifier turns the plus ungreedy so that it matches only the first character. And what's the "$3" about? Are you doing this? echo preg_replace('/http:\/\/(www\.|)zshare\.net\/video\/([^\/]+)/Uis', '$3', 'http://www.zshare.net/video/541070871c7a8d9c'); echo "\n"; I think someone mentioned that the index "$3" doesn't exist. If you change it to "$2" you would get the correct result because "$2" mathces "5" and the rest ("41070871c7a8d9c") remains unreplaced. At least that's what I think is going on... /Nisse -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php