I use the following UDF:

<cfscript>
function fnNumbersOnly(str) {
        return reReplace(str,"[^[:digit:]]","","all");
}
</cfscript>



-----Original Message-----
From: Matthew Smith [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, August 14, 2007 3:47 PM
To: CF-Talk
Subject: strip all non-numeric characters from a string


We are having an issue with users entering their phone numbers and credit
card info.  How would I strip a string of all non-numeric characters.  I'm
sure it involves rereplace() but I'm no good with regular expressions.
Thanks for any help.

Right now for the credit card I have this which just strips out spaces and
dashes: <cfset attributes.billingCardNumber =
replace(attributes.billingCardNumber, " ", "", "all")> <cfset
attributes.billingCardNumber = replace(attributes.billingCardNumber, "-",
"", "all")>





~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Check out the new features and enhancements in the
latest product release - download the "What's New PDF" now
http://download.macromedia.com/pub/labs/coldfusion/cf8_beta_whatsnew_052907.pdf

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:286197
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to