Convert2Number(strVal)
Last updated November 15, 2002
Version: 1 | Requires: ColdFusion 5 | Library: MathLib
Description:
This function will take any string and strip out all characters that are not (-.0123456789) and will then determine it's numeric value.
Return Values:
Returns a number.
Example:
Parameters:
| Name | Description | Required |
|---|---|---|
| strVal | Value to convert. | Yes |
Full UDF Source:
<cfscript>
/**
* Converts any numeric string (even ones with currancy symbols to a number).
*
* @param strVal Value to convert. (Required)
* @return Returns a number.
* @author Glenn Wilson (glenn.wilson@quotegen.com)
* @version 1, November 15, 2002
*/
function Convert2Number(StrVal){
var regStr = "[^/.0123456789-]";
return Val(REReplace(StrVal,regStr,"","all"));
}
</cfscript>
Search CFLib.org
Latest Additions
John Bartlett added
browserDetect
4 day(s) ago
Rob Brooks-Bilson added
listCompare
7 day(s) ago
Stephen Withington added
formToNameValueP...
15 day(s) ago
anthony petruzzi added
parseExcel
20 day(s) ago
Pablo Varando added
returnRandomHEXC...
21 day(s) ago
Top Rated
QueryStringChang...
Rated 5.0, 10 time(s)
formToNameValueP...
Rated 5.0, 5 time(s)
HTMLSafe
Rated 5.0, 4 time(s)
viewCSS
Rated 5.0, 4 time(s)
generateRandomKe...
Rated 5.0, 3 time(s)