what is the most efficient regex (vim/perl) to replace 100 'a' characters with 300 'b' characters. I can get the search part correct :%s/a\{100}/?????? but the 'replace' portion eludes me.
1 Answer
This can be done with :%s/a\{100}/\=repeat('b',100)/
-
that does it. i'd been using the search form in the replace portion and just did not work. i don't know how to mark this as the correct answer, but it does exactly what i was looking for. thanks. Nov 22, 2018 at 1:19
-
@iohannfust click the greyed-out check mark next to the answer to mark it as “accepted”– D. Ben Knoble ♦Nov 22, 2018 at 3:06