Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Insert commas into numeric field using regular expression

Posted on 2002-03-26
5
Medium Priority
?
832 Views
Last Modified: 2008-02-01
I need to take a number (9123456) and insert commas so that it looks like (9,123,456). I have it written in javascript for the client side but I need a vbscript version for the server-side and I have not used regular expressions in vbscript yet so I need some help.
0
Comment
Question by:idalton
  • 2
  • 2
5 Comments
 
LVL 11

Expert Comment

by:thunderchicken
ID: 6897348
If your local currency settings are for $

<%
  dim number
  number = 9123456
  Response.Write right(formatcurrency(number,0),len(formatcurrency(number,0))-1)
%>
0
 
LVL 18

Accepted Solution

by:
mgfranz earned 200 total points
ID: 6897364
No RegExp needed, just use FormatNumber;

<%
theNum = FormatNumber("9876543210", 0)
Response.Write theNum
%>

The "0" indicates the number of decimal places to write after the .
0
 

Author Comment

by:idalton
ID: 6897374
I don't want to rely on local settings. I would prefer to handle via regular expression logic.
0
 
LVL 18

Expert Comment

by:mgfranz
ID: 6897388
Do you have to use a RegExp?
0
 

Author Comment

by:idalton
ID: 6897396
this solution works fine. thanks
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question