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.
This is not a good way to use regular expressions.
Instead, use the string formatting features of your language:
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)
Doing it this way also makes eliminating ranges of numbers trivial.