CFLib.org – Common Function Library Project

StripUrl(URL)

Last updated September 06, 2001

author

Steven Ketterman

Version: 1 | Requires: CF5 | Library: StrLib

Description:
This Function will strip the following:

  • http://
  • http://www.
  • www.

Return Values:
Returns a string.

Example:

<cfoutput>
#StripUrl("http://www.btp.pghsonicweb.com/someonehelp.htm")#
</cfoutput>

Parameters:

Name Description Required
URL URL to strip Yes

Full UDF Source:

/**
 * The function deletes non-needed characters (ie. http://)
 * 
 * @param URL      URL to strip 
 * @return Returns a string. 
 * @author Steven Ketterman (beans@pghsonicweb.com) 
 * @version 1, September 6, 2001 
 */
function StripUrl(UrltoStrip)
{
  Var oldurl = UrltoStrip;
  
  if(oldurl CONTAINS 'http://www.'){
      oldurl = ReplaceNoCase(oldurl, 'http://www.', '');
  }
  if(oldurl CONTAINS 'http://'){
      oldurl = ReplaceNoCase(oldurl, 'http://', '');
  }
  if(oldurl CONTAINS 'www.'){
      oldurl = ReplaceNoCase(oldurl, 'www.', '');
  }
  
  oldurl = ListFirst(oldurl, '/');
  Return OldUrl;
}

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson