0

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

1 Answer 1

1

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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