Solved

Insert commas into numeric field using regular expression

Posted on 2002-03-26
5
824 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 50 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Attaching a file to SMTP in Classic ASP 1 42
XML Parsing Classic ASP 5 64
FileUp - Classic ASP 5 19
Pass asp session variable to a js function in an asp script 6 27
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 have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

808 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