0

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

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. – iohann fust Nov 22 '18 at 1:19
  • @iohannfust click the greyed-out check mark next to the answer to mark it as “accepted” – D. Ben Knoble Nov 22 '18 at 3:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.