Reputation: 55
Say I have a regex of /\n(\d)+/
.
Let's say I test it against some random text:
aaaaaaaaaa
5aaaaaaaaa
4707aaaaaa
aaaaaaaaaa
923aaaaaaa
Is there a way I can get the number of times \d
was repeated for each match?
I ask this because I'm using regex to do a find and replace on Notepad++ and was hoping I could achieve this end-result:
aaaaaaaaaa
Xaaaaaaaaa
XXXXaaaaaa
aaaaaaaaaa
XXXaaaaaaa
Upvotes: 2
Views: 172
Reputation: 18490
If you want to match each digit at ^
start of line, the \G
anchor can be used to chain matches. It matches at start of the string or where the previous match ended.
(?:\G|^)\d
Replace with
X
Upvotes: 3