[Javascript] thousand separator

George Pitcher george.pitcher at ingenta.com
Thu Jun 3 08:18:03 CDT 2004


Shawn,

Not sure if it applies, but in Germany, for example, the thousands separator
is a dot and the decimal separator is a comma.

Esperanto for ever!

George in Oxford [period]

> -----Original Message-----
> From: javascript-bounces at LaTech.edu
> [mailto:javascript-bounces at LaTech.edu]On Behalf Of Shawn Milo
> Sent: 3 June 2004 1:07 pm
> To: [JavaScript List]
> Subject: Re: [Javascript] thousand separator
>
>
> Okay, I've jury-rigged a solution.
> It ain't pretty, but it works.
>
> I've just used a simplified regex
> and a 'while' loop.
>
> Suggestions welcome.
>
> Shawn
>
>       <script type="text/javascript">
>
>          function addCommas(someNum){
>
>             while (someNum.match(/^(.*\d)(\d{3}(\.|,|$).*$)/)){
>                someNum =
> someNum.replace(/^(.*\d)(\d{3}(\.|,|$).*$)/, '$1,$2');
>             }
>             return someNum;
>
>          }
>
>          alert(addCommas('6541684.23'));
>          alert(addCommas('1000.1'));
>          alert(addCommas('34562346346'));
>          alert(addCommas('3456345634563456'));
>          alert(addCommas('763773763567.342'));
>          alert(addCommas('123456.234'));
>
>       </script>
>
>
>
>
>
>
> ----- Original Message -----
> From: "andy susanto" <andy78 at centrin.net.id>
> Date: Thu, 3 Jun 2004 07:36:03 +0700
> To: <javascript at LaTech.edu>
> Subject: [Javascript] thousand separator
>
> > hai,
> >
> > is there any script that can formating number with thousand
> separator ?,
> >
> > if not how to create that script ?
> >
> > TIA,
> >
> > andy
> > _______________________________________________
> > Javascript mailing list
> > Javascript at LaTech.edu
> > https://lists.LaTech.edu/mailman/listinfo/javascript
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
>




More information about the Javascript mailing list