Solved

Insert commas into numeric field using regular expression

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
ODBC connection string for ODBC 6.01 24 65
Leverage browser caching 2 46
Dreamweaver server behavior gone 6 76
Copy only dates 3 70
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now