If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Enjoy an ad free experience by logging in. Not a member yet? Register.

Also, these are evaluating as strings, not integers. Did you want integer values?

^_^

If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.* The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".

Yes, you're right!!
In my problem i do translate from number ex : 125020 to letters, one hundred twenty-five thousand and twenty!
And i use more if and put an condition if number from 1 to 9
But can you explain me what means this symbol ? : if ( ( /^1[1-9]$/ ).test(s) )

In my problem i do translate from number ex : 125020 to letters, one hundred twenty-five thousand and twenty!

So what is the point in testing just the FIRST TWO characters, as your ugly code was trying to do?

But can you explain me what means this symbol ? : if ( ( /^1[1-9]$/ ).test(s) )

/ ==>> beginning of a regular expression
^ ==>> beginning of text (that is, nothing can appear before what we are testing)
1 ==>> the digit 1, only. Nothing else allowed.
[1-9] ==>> any digit from 1 to 9
$ ==>> the end of the text (nothing can appear after what we are testing)
/ ==>> the end of the regular expression

In short, that says "Look for text that has a 1 as the first character and a 1 through 9 as the second character and is exactly 2 characters long."

But who cares? It's entirely irrelevant to what you really need.

An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.

The proposed code treats strings rather than numbers. The function anyNumber cuts simply and logically the numbers in three digits slices with a replace method (the regular expression captures each one to three digit slice, before a multiple of three digits) not to replace this slices with return values, but only to call the function for triplets and to define the future response chn...

EDIT : Change the chn.replace(/tre$/g,'tré') with a chn.replace(/(\w)tre\b/g,'$1tré') to replace tre by tré only at the end of a word (after a letter).