NumbersOnly(str)
Last updated September 06, 2002
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");
}
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