CFLib.org – Common Function Library Project

getExtension(name)

Last updated May 9, 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 "";
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson