Feature Request - lsparsenumber() to strip characters

I am working on an old program that used OpenBlueDragon as its cfml engine. I do not know if it was made special, or something changed in Coldfusion after v8, but the lsparsenumber() would strip out letters from a number, and return the number.

I recall it being in the Coldfusion docs when I googled it, because that is how I found that it did that. And now, as I work through fixing this app, that seems to be the number 1 road block making this app work right.

I know I could

<cfset num = ReReplaceNoCase(num,"[^0-9.]","","ALL")>

But the amount of times lsparsenumber was used to clean a number… phew…

Anyway, am I just day dreaming of something that did not exist or was this changed sometime after v8?

Lucee only strips out whitespace, anything else needs to be cleaned up as you are doing manually, as Lucee simply uses underlying java implementation.

I’d call your function mask or remask so you could then add a whole range of masked variations in your code :wink:

usage: mask( type, value )

so mask('integer','10.1 weeks') would return 10

and mask('number','10.1 weeks') or mask('float',10.1 weeks')
would return 10.1

Or just drop your code in the context directory luce

1 Like

I have thought about putting it on my todo list, but at the moment all I have to do is use:

ReReplaceNoCase(num,"[^0-9.]","","ALL")