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