I'm having trouble getting figuring out a couple of S&Rs for some very large documents I'm editing.
- I'd like to replace all instances of
[##dname = KOxxx]where xxx is any three-digit number withVariable KOxxx
I came up with [##dname = KO\(\d\+\)] which correctly finds the text I'd like to replace, but I can't for the life of me figure out how to get the "xxx" to be preserved in the replace. Any ideas?
- I'd like to remove the characters > and < around a string. Example: >xxx< where xxx is anywhere from 2-5 characters long.
I had been using the following regex successfully a few months ago, but now it doesn't seem to be working.
%s#>\(\w\{2,5}\)<#\1#g
Any ideas why this might be failing?
Thanks in advance!
\d\+is one or more numbers, not three numbers.\d{3}would be three numbers. Here\w\{2,5}you are saying the first curly brace is literal, take off the backslash,\w{2,5}to say 2 to 5 word characters (make it a.if you want any character). I'm not sure how vim's find and replace works I'd presume your grouped value for thexxxwould be in$1or\1.