jamesxg1 Posted December 14, 2010 Share Posted December 14, 2010 Hiya peeps, I am using preg_match to validate URLS; preg_match("/(((https?|ftp|gopher):\/\/|(mailto|file|news)[^' <>\"]+|(www|web|w3).[-a-z0-9.]+)[^' .,;<>\":]/i", $this->_searchString) I works great, the only issue I have is I am using it in an if statment, and what I need to do is something like this. if(preg_match("/(((https?|ftp|gopher):\/\/|(mailto|file|news)[^' <>\"]+|(www|web|w3).[-a-z0-9.]+)[^' .,;<>\":]/i", $this->_searchString)) { CHECK IF $this->_searchString has http:// at the start of it or if it has a / at the end and remove them if it does. I need $this->_searchString to end up with only www.SITE.co.uk before I can input it into the relevant function. } else { } Many thanks, James. Quote Link to comment Share on other sites More sharing options...
MMDE Posted December 14, 2010 Share Posted December 14, 2010 from what the thread title "wants", look into preg_replace(); Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted December 14, 2010 Share Posted December 14, 2010 Maybe use functions that are built for this if(filter_var($this->_searchString, FILTER_VALIDATE_URL)) { $this->_searchString = parse_url($this->_searchString, PHP_URL_HOST); } Quote Link to comment Share on other sites More sharing options...
jamesxg1 Posted December 14, 2010 Author Share Posted December 14, 2010 Thanks mate, worked a charm . Many thanks, James. Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted December 14, 2010 Share Posted December 14, 2010 Thanks mate, worked a charm . Many thanks, James. Just noticed your sig. I love it! Quote Link to comment 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.