I have a list like the following:
32,981,250BLACKOPS
32,981,250
28,718,750BLACKOPSI
28,331,250BLACKOPS
29,493,750BLACKOPS
Note that this is only a sample list to explain my problem.
I want to move the text following comma-separated numbers to a new line, resulting in:
32,981,250
BLACKOPS
32,981,250
28,718,750
BLACKOPSI
28,331,250
BLACKOPS
29,493,750
BLACKOPS
I tried the following regex in Notepad++:
Find what: (\d{1,3}(?:,\d{3})+)(\S.*)
Replace with: \1\n\2
However, it didn't work as expected and gave me this incorrect result:
32,981,250
BLACKOPS
32,981
,250
28,718,750
BLACKOPSI
28,331,250
BLACKOPS
29,493,750
BLACKOPS
The issue is that the regex is splitting some numbers incorrectly, even when there is no extra text after the number.
Where is my regex going wrong, and how can I fix it?
You may match using this regex:
^\d++(?:,\d+)*+\K.+
And replace it with:
\n$0
RegEx Deails:
^
: Start\d++
: Match 1+ digits. ++
is possessive quantifier to disallow any backtracking(?:,\d+)*+
: Match comma followed by 1+ digits. Repeat this group 0 or more times. *+
is possessive quantifier to disallow any backtracking.\K
: Reset matched info.+
: Match 1+ of any character till the end