I have this function where I need to get the 10 digit phone number.
<cffunction name="StandardPhoneNumber"
access="public"
hint="Returns a 10 digit phone number in a numeric format ex. 8883334444"
Description="We use a standard numeric only phone number. We stripped the non numeric characters and return 10 digit">
<cfargument name="phoneNumber" required="true" >
<!--- we need a little bit of processing here coz of a bug where a space is returned at the start of the number --->
<cfset local.phoneNumber = right(REReplace(arguments.phoneNumber, "[^0-9]", "", "ALL"),10) />
<cfreturn trim(local.phoneNumber)/>
</cffunction>
For some reason the returned value is also returning some space.
Example input value '+5122131151' will return ' 5122131151' (a space in front of 5)
The rereplace function is added
REReplace(arguments.phoneNumber, "[^0-9]", "", "ALL")
so that it can accept phone number even with dashes +1888-333-4444 and return 10 digit phone number. This is for US phone number only where the standard phone number is 10 digit.