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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.