How to add thousands of delimiters with reg ex?

I use this free RegExp Designer , which finds and replaces. How to search all numbers and add thousands of separators?

Input:      <node num='12345678'>
Output:     <node num='12,345,678'>
+3
source share
2 answers

To reformat numbers only in the "num" attribute values, you can do this:

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

, .NET, RegExp Designer. lookbehinds, . Java lookbehinds , , , {min,max} quantifier :

(?<=num='\d{1,20})(?=(?:\d{3})+(?!\d))

, lookbehinds.

EDIT: ; , lookbehinds:

(num='\d{1,3}|\G\d{3})(?=(?:\d{3})+(?!\d))

.:)

EDIT2: , - "$1,"

+7
s/(?<=\d)(?=(\d\d\d)+(?!\d))/,/g

, , , - , , , , .

+5

Source: https://habr.com/ru/post/1714312/


All Articles