Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Insert commas into numeric field using regular expression

Posted on 2002-03-26
5
Medium Priority
?
829 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

722 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