ted_chou12 Posted November 11, 2007 Share Posted November 11, 2007 I tried to learn a bit, simple ones I understand, but hard ones I cant do, how do you replace the http:// in front of the url using preg replace? $link = preg_replace("/^(http:\/\/)?(.*?)/i", "$1", $link); This is what I got, it doesnt work at all. I don't think is right anyways. Thanks for your corrections. Ted. Link to comment https://forums.phpfreaks.com/topic/76842-solved-preg_replace-http-in-url/ Share on other sites More sharing options...
ted_chou12 Posted November 11, 2007 Author Share Posted November 11, 2007 sorry, I finally got it working... however, I am having a problem: $links444 = preg_replace("`(http://)?(www.)?(.*?)`is", "$3", $link2); for this code, when I tried wwww.domain.com, it strips the www. and becomes wdomain.com, I know I am bored , and picky, but is it possible to modify it a bit so that when there are wwww. or it detects something different, it doesn't remove the "www."? Thanks. Ted Link to comment https://forums.phpfreaks.com/topic/76842-solved-preg_replace-http-in-url/#findComment-389138 Share on other sites More sharing options...
rajivgonsalves Posted November 11, 2007 Share Posted November 11, 2007 your expression should be something like $links444 = preg_replace("`^http://`is", "", $link2); Link to comment https://forums.phpfreaks.com/topic/76842-solved-preg_replace-http-in-url/#findComment-389142 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.