nicob Posted December 7, 2008 Share Posted December 7, 2008 I tried "/\%3a\%2f\%2f/", and "/%3a%2f%2f/", but no luck in preg_replace. ( I want to replace this in <a href="http%3a%2f%2fwww.hello.com"> ) Anyone? Link to comment https://forums.phpfreaks.com/topic/135971-cant-preg_replace-3a2f2f-with/ Share on other sites More sharing options...
veridicus Posted December 7, 2008 Share Posted December 7, 2008 Any particular reason you're using a regex instead of urlencode? Link to comment https://forums.phpfreaks.com/topic/135971-cant-preg_replace-3a2f2f-with/#findComment-708794 Share on other sites More sharing options...
.josh Posted December 7, 2008 Share Posted December 7, 2008 any reason you can't do echo urldecode($string); ? Link to comment https://forums.phpfreaks.com/topic/135971-cant-preg_replace-3a2f2f-with/#findComment-708796 Share on other sites More sharing options...
nicob Posted December 7, 2008 Author Share Posted December 7, 2008 I found the solution "/%..%..%../" I really don't understand why preg_replace can't work with %aa or %a1 ??? I've never heard of 'urlencode'. Sounds interesting. Thanks! Link to comment https://forums.phpfreaks.com/topic/135971-cant-preg_replace-3a2f2f-with/#findComment-708802 Share on other sites More sharing options...
.josh Posted December 7, 2008 Share Posted December 7, 2008 btw $string = '<a href="http%3a%2f%2fwww.hello.com">'; $string = preg_replace("/%3a%2f%2f/", "://", $string); works fine for me. Link to comment https://forums.phpfreaks.com/topic/135971-cant-preg_replace-3a2f2f-with/#findComment-708803 Share on other sites More sharing options...
nicob Posted December 7, 2008 Author Share Posted December 7, 2008 btw $string = '<a href="http%3a%2f%2fwww.hello.com">'; $string = preg_replace("/%3a%2f%2f/", "://", $string); works fine for me. strange. I'm using this in a script with multiple replacements $rep = preg_replace($listone, $listtwo, $val); I'm using php v5.2.5 Link to comment https://forums.phpfreaks.com/topic/135971-cant-preg_replace-3a2f2f-with/#findComment-708809 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.