Created
November 2, 2018 16:33
-
-
Save trycf/03164081321977462f8e9e4916476ed3 to your computer and use it in GitHub Desktop.
TryCF Gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
all_employees = QueryNew("userdefined,hello", "varchar,varchar", | |
[ | |
["test","pure text"], | |
["2","number as varchar"], | |
["03","leading zero"], | |
[" 4 ","leading and trailing spaces"], | |
["5 ","extra trailing spaces"], | |
[" 6","extra leading spaces"], | |
["165e73","scientific notation"], | |
["1.5","decimal"], | |
["1,5","comma-delimited (or non-US decimal)"], | |
["1.0","valid decimal"], | |
["1.","invalid decimal"], | |
["1,000","number with comma"] | |
] | |
) | |
//writedump(all_employees) ; | |
retval = [] ; | |
for (r in all_employees) { | |
retval.append( | |
{ | |
"1 - RowInput" : r.userdefined.replace(" ","*","all") , // Replace space with * for output visibility. | |
"2 - IsNumeric?" : ISNUMERIC(r.userdefined) , | |
"3 - FirstOutput": ( ISNUMERIC(r.userDefined) ? right("00000000"&r.userdefined,8) : r.userDefined ) , | |
"4 - ValOutput" : ( ISNUMERIC(r.userDefined) ? right("00000000"&val(r.userdefined),8) : r.userDefined ) , | |
"5 - TrimOutput" : ( ISNUMERIC(r.userDefined) ? right("00000000"<rim(rtrim((r.userdefined))),8) : r.userDefined ) | |
} | |
) ; | |
} | |
writeDump(retval) ; | |
</cfscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment