CFLib.org – Common Function Library Project

NumbersOnly(str)

Last updated September 6, 2002

author

Mindframe, Inc.

Version: 1 | Requires: CF5 | Library: StrLib

Description:
This udf has the intended purpose of formatting a phone number that is in a (xxx) xxx-xxxx to a xxxxxxxxxx format.

Return Values:
Returns a string.

Example:

<cfset phoneNumber = "(612) 204-0320">
<cfoutput>
My Phone ## is #phoneNumber#<br>
My NumbersOnly Phone ## is #NumbersOnly(phoneNumber)#
</cfoutput>

Parameters:

Name Description Required
str String to format. Yes

Full UDF Source:

/**
 * Strips all non-numeric characters from a string.
 * Modified by RCamden to use one line of code.
 * 
 * @param str 	 String to format. (Required)
 * @return Returns a string. 
 * @author Mindframe, Inc. (info@mindframe.com) 
 * @version 1, September 6, 2002 
 */
function NumbersOnly(str) {
	return reReplace(str,"[^[:digit:]]","","all");
}
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