Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7811021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:00:29+00:00 2026-06-02T04:00:29+00:00

I have to put thousand separator between numbers. I have done till now: Input

  • 0

I have to put thousand separator between numbers. I have done till now:

Input string

1852  
2589653  
586699  
8542.28

The find pattern

(?<=\d)(?=(?:\d{3})+(?!\d))  

replace-with

,  

result

1,852  
2,589,653  
586,699  
8,542.28 

TODO
I want to eliminate all year ranges from 1700 to 2010, from match-collection.

Anyone have any idea. All suggestions are welcome. Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T04:00:31+00:00Added an answer on June 2, 2026 at 4:00 am

    This is not a good way to use regular expressions.

    Instead, use the string formatting features of your language:

    • Use a simple regular expression to find the numbers, if you have to extract them from text.
    • Convert them to floating point or integer numbers (as appropriate)
    • Use a string format specifier to say you would like them output with a thousands separator.

    For example, here’s a shell transcript where I extract a number from a string and format it with a comma thousands separator: (Python 2.x)

    In [12]: import re
    
    In [13]: number_pattern = re.compile(r"\d+(.\d+)") #positive integer or floating point number
    
    In [14]: mystring = "The size of the rocket is 3141592.6."
    
    In [15]: number_string = number_pattern.search(mystring).group() #extract the number as a string
    
    In [16]: number_string
    Out[16]: '3141592.6'
    
    In [18]: number = float(number_string) #convert to number
    
    In [19]: '{:,}'.format(number) #format with thousands separator
    Out[19]: '3,141,592.6'
    

    Doing it this way also makes eliminating ranges of numbers trivial.

    if (number > 1700) or (number < 2100):
        pass #do something
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

To debug our Android code we have put System.out.println(string) which will let us know
I have a few thousand word files which some of my colleagues have put
I have put together a navigation bar which expands a submenu on hover. See
I have put together a .net winform application which consumes a wcf service exposed
i have put my site in dropbox so you can see it http://dl.dropbox.com/u/13722201/Dorset%20Designs/home.html when
I have put together an API that responds to a POST request by putting
I have put together an image scroller using jquery, like this function rotateImages(whichHolder, start)
I have put some aliases in my .bashrc to open a group of project
i have put fckeditor in jsp page. I want to get the value whatever
I have put the following method in my master page. It works when I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.