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? Quote 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? Quote 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); ? Quote 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! Quote 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. Quote 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 Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.