I have a string like 18NTC101L , which I can search by \v[0-9]{2}[A-Z]{3}[0-9]{3}L. Now, I just want to replace the L at the end with letter T.

How I can do that?

  • 2
    One way: use \zs and \ze in your pattern to surround L then :%s/{pattern}/T/.
    – B Layer
    Commented May 25, 2021 at 13:26
  • \d instead of [0-9] and \u (or maybe \U) instead of [A-Z] should work too
    – D. Ben Knoble
    Commented May 25, 2021 at 14:58

1 Answer 1


use \zs

:h \zs sets the start of the search, meaning that the next char is the first one of the whole match. So in the end you specify only T to replace with.


use grouping () together with \1

:h \1 and :h \(\)


Group everything till L and replace with what was matched in a group \1 and T

Probably more options are available...

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.