Haven't tested your code but from a rapid look it would work. The issue here is that I don't understand why my expression doesn't catches the full match and emits the first character? On Fri, Mar 6, 2009 at 10:17 PM, Adam <adiszakacs@xxxxxxxxx> wrote: > would this not work? : > > <?php > > $string = "http://www.zshare.net/video/541070871c7a8d9c"; > $replaceWithThis = 'HELLYES-'; > > echo $string."\n"; > echo preg_replace('/\S+video\//',$replaceWithThis,$string)."\n"; > echo $replaceWithThis.substr($string, strripos($string, '/')+1, > strlen($string))."\n"; > echo $replaceWithThis.substr(strrchr($string, '/'), 1, > strlen(strrchr($string, '/'))); > > > ?> > > OUTPUT: > > C:\>php test.php > http://www.zshare.net/video/541070871c7a8d9c > HELLYES-541070871c7a8d9c > HELLYES-541070871c7a8d9c > HELLYES-541070871c7a8d9c > C:\> > > On Fri, Mar 6, 2009 at 2:32 PM, Nitsan Bin-Nun <nitsan@xxxxxxxxxxxx> > 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 > > http://www.guba.com/watch/2000821351 > > http://www.veoh.com/videos/v4609719YfsCFpf > > > > > > REGEX USED (with Uis modificators) > > ---- > > http:\/\/(www\.|)zshare\.net\/video\/([^\/]+) $3 > > http:\/\/(www\.|)guba\.com\/watch\/([0-9]+) $3 > > http:\/\/(www\.|)veoh\.com\/videos\/([^\/]+) > > > > THE RETURNED STRING > > ---- > > 41070871c7a8d9c > > 000821351 > > 4609719YfsCFpf > > > > If you will go through this carefully you will notice that the first > > character of each matching group is being deleted. > > The regex's and the replacements string are being fetched from the > database > > (mysql) and goes straight to the preg_replace function with the original > > string. > > > > I have no idea why this happens. > > I'm looking forward for your opinions and suggestions. > > > > Regards, > > Nitsan > > > > > > -- > Adi... >