I'm not looking for other ideas, the main thing here is that I have about 30-100 regex's in the database and the script fetches them and applies them to the string. I can't build again the engine and I'm not going to do that. I'm trying to solve my problem ;) If you have any ideas regarding my issue and not going in another way this would be very appreciated. Thank you again for trying to help. On Fri, Mar 6, 2009 at 11:40 PM, Jim Lucas <lists@xxxxxxxxx> wrote: > 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 > > 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 > > > > In my opinion... > > http://us3.php.net/parse_url is your friend here... > > <?php > > $urls[] = 'http://www.zshare.net/video/541070871c7a8d9c'; > $urls[] = 'http://www.guba.com/watch/2000821351'; > $urls[] = 'http://www.veoh.com/videos/v4609719YfsCFpf'; > > $url_paths = array(); > > foreach ( $urls AS $id => $url ) { > $url_paths[$id] = parse_url($url, PHP_URL_PATH); > } > > print_r($url_paths); > > foreach ( $url_paths AS $paths ) { > list( , ,$value) = explode('/', $paths, 3); > echo $value; > } > > ?> > > The above outputs the following: > > > > -- > Jim Lucas > > "Some men are born to greatness, some achieve greatness, > and some have greatness thrust upon them." > > Twelfth Night, Act II, Scene V > by William Shakespeare >