Mr Chris Posted April 14, 2010 Share Posted April 14, 2010 Hello, I'm trying to get together a regular expression to remove http:// if it exists in a url string: <?php $web_url = "http://www.wewebbbywebsiteshere.com"; $website = preg_replace('/^(http¦ftp¦news)s?:\/+/i', '', $web_url); echo $website; ?> Anyone help as the above does not seem to work? Thanks Link to comment https://forums.phpfreaks.com/topic/198491-regular-expression-to-remove-http/ Share on other sites More sharing options...
trq Posted April 14, 2010 Share Posted April 14, 2010 Hello, I'm trying to get together a regular expression to remove http:// if it exists in a url string: If http:// is all your really looking to remove you don't need regular expressions. $str = str_replace('http://', '', $str); Link to comment https://forums.phpfreaks.com/topic/198491-regular-expression-to-remove-http/#findComment-1041568 Share on other sites More sharing options...
salathe Posted April 14, 2010 Share Posted April 14, 2010 You want to use a solid pipe (|) rather than a broken pipe (¦). Link to comment https://forums.phpfreaks.com/topic/198491-regular-expression-to-remove-http/#findComment-1041572 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.