CFLib.org – Common Function Library Project

getExtension(name)

Last updated May 09, 2003

author

Alexander Sicular

Version: 2 | Requires: CF5 | Library: FileSysLib

Description:
Submit a filename and function will return extension. If no period exists in the filename, an empty string is returned.

Return Values:
Returns a string.

Example:

<cfset tmp = "some text.stuff. . .this.that">
<cfoutput>
getExtension(tmp) = #getExtension(tmp)#
</cfoutput>

Parameters:

Name Description Required
name File name to use. Yes

Full UDF Source:

/**
 * Returns extension defined by all characters following last period.
 * v2 by Ray Camden
 * 
 * @param name      File name to use. (Required)
 * @return Returns a string. 
 * @author Alexander Sicular (as867@columbia.edu) 
 * @version 2, May 9, 2003 
 */
function getExtension(name) {  
    if(find(".",name)) return listLast(name,".");
    else return "";
}

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