Jump to content

if an input has specific characters, strip them.


jamesxg1

Recommended Posts

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.