I want to preface by saying I am a novice at regex, and I've spent a considerable amount of time trying to solve this myself using tutorials, online docs, etc. I have also gone through the suggested answers here.
Now here is my problem: I have 267 lines like this, and each county is different.
<SimpleData name="NAME">Angelina</SimpleData>
What I need to do is to replace NAME with COUNTY and keep the rest the same including the proper county name:
<SimpleData name="COUNTY">Angelina</SimpleData>
I used the following Find to find all the lines that I wanted to change, and was successful.
<SimpleData name="NAME">[\S\s\n]*?</SimpleData>
It's probably not the best way to do this, but it worked.
I hope I've explained this so it can be understood. Thanks, Paul
You need to use capturing groups with backreferences in the replacement field:
Find What: (<SimpleData name=")NAME(">[\S\s\n]*?</SimpleData>)
Replace With: $1COUNTY$2
See the regex demo
As per regular-expressions.info:
Besides grouping part of a regular expression together, parentheses also create a numbered capturing group. It stores the part of the string matched by the part of the regular expression inside the parentheses.
If your regular expression has named or numbered capturing groups, then you can reinsert the text matched by any of those capturing groups in the replacement text. Your replacement text can reference as many groups as you like, and can even reference the same group more than once. This makes it possible to rearrange the text matched by a regular expression in many different ways.
Note that, in VSCode, you can't use named groups.