ballhogjoni Posted September 25, 2008 Share Posted September 25, 2008 Hi all, I am trying to find a url in a string and replace with another url but I can't seem to get this to work. I know the first parameter is correct. Any help would be great! $sCardHoldersSay = preg_replace( '/(http:\/\/www1\.xxxxxxxxx\.com\/partners\/links\/cardholders\/details\.asp\?idmin=)([0-9]+)(&tempid=568261)/',FACS_href.'/card-holders-say/'.$url_1.'/'.preg_replace('/ /','-',$sIssuer).'.html',$sDefinitionList ); Link to comment https://forums.phpfreaks.com/topic/125864-trying-to-preg_replace-but-not-working/ Share on other sites More sharing options...
sKunKbad Posted September 25, 2008 Share Posted September 25, 2008 You should try the regex forum Link to comment https://forums.phpfreaks.com/topic/125864-trying-to-preg_replace-but-not-working/#findComment-650845 Share on other sites More sharing options...
xtopolis Posted September 26, 2008 Share Posted September 26, 2008 If I had to guess something you should try escaping the : => \: $sCardHoldersSay = preg_replace( '/(http:\/\/www1\.xxxxxxxxx\.com.... I believe the ":" is special character that needs to be escaped \: $sCardHoldersSay = preg_replace( '/(http\:\/\/www1\.xxxxxxxxx\.com..... I know I have to escape it when I use preg_match.. but I might be wrong here. Link to comment https://forums.phpfreaks.com/topic/125864-trying-to-preg_replace-but-not-working/#findComment-650870 Share on other sites More sharing options...
ballhogjoni Posted September 26, 2008 Author Share Posted September 26, 2008 No errrors, i figured it out. I decided to echo out the result and see what the isszue was, come to find out I forgot I had another preg_replace() rewriting what I change earlier. So I was rewriting the url on accident. Its fixed now though. Sorry for wasting your time Link to comment https://forums.phpfreaks.com/topic/125864-trying-to-preg_replace-but-not-working/#findComment-650891 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.