<!--- ============ JUSTNUMBERS() - CONVERT STRING TO ONLY NUMBERS ============ --->
<CFFUNCTION name="JustNumbers" returnType="string" output="no" hint="This function will take input from a string and return only numbers.">
<CFARGUMENT name="InputString" required="True" type="string"> <!--- This is the string to be converted --->
<CFARGUMENT name="blnInt" required="False" type="boolean" default="0"> <!--- Setting this to 1 will return just a number. It will strip out any non-digit characters, including '.' and '-'. The default will return a number including '-' and '.' characters. --->
<!---
###################################################
## Author: George Jaros ##
## Script Name: ColdFusion JustNumbers Function ##
## Copyright 2006 George Jaros & Web 2 Market ##
## www.georgejaros.com www.web2market.com ##
## This code may be replicated as long as ##
## this header statement is included. The ##
## Instructions below may be removed. ##
###################################################
--->
<CFSET ReturnValue = 0>
<CFIF blnInt>
<CFSET ReturnValue = REReplace(InputString,"[^[:digit:]]","","ALL")>
<CFELSE>
<CFSET ReturnValue = REReplace(InputString,"[^0-9\.\-]","","ALL")>
</CFIF>
<CFIF Trim(ReturnValue) NEQ "">
<CFRETURN Trim(ReturnValue)>
<CFELSE>
<CFRETURN " ">
</CFIF>
</CFFUNCTION>
<!--- ============ END JUSTNUMBERS() ============ --->