what is the most efficient regex (vim/perl) to replace 10 'a' characters with 1 'c' character followed by 100 'b' characters?

this does not work: :%s/a{10}/\=repeat('c',1)\=repeat('b',100)/g


This can be done with :%s/a\{10}/\=repeat('c',1).repeat('b',100)/g

  • 1
    even shorter: %s/a\{10}/\='c'.repeat('b',100) Nov 23 '18 at 15:53
  • the 'dot' concatenation did the trick. Nov 24 '18 at 17:58

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.