This is for Notepad . I am trying to Find a word between two words; and if found, mark the whole thing.
<lootgroup name="Random1" count="1">
<item group="filler"/>
<item group="filler"/>
</lootgroup>
<lootgroup name="Random2" count="1">
<item group="filler"/>
<item group="schematics"/>
<item group="filler"/>
</lootgroup>
<lootgroup name="Random2" count="1">
<item group="filler"/>
<item group="schematics"/>
<item group="filler"/>
<item group="schematics"/>
</lootgroup>
So I want to Find "schematics" between <lootgroup and </lootgroup>; and if found, mark/select all lines including <lootgroup and </lootgroup>.
I know about <lootgroup(.*?)</lootgroup> will select everything in between but I cannot figure out what to replace (.*?) with to match only if schematics is present between the two.
Number of "Item Groups" varies and "Item Group" is not always the name. That's why I'm searching for "schematic".
Using Notepad Find and Mark function.
Much appreciated.
CodePudding user response:
- Ctrl M
- Find what:
<lootgroup (?:(?!</lootgroup>).) \bschematics\b(?:(?!</lootgroup>).) </lootgroup> - Replace with:
LEAVE EMPTY - CHECK Match case
- CHECK Wrap around
- CHECK Regular expression
- CHECK
. matches newline - Mark All
Explanation:
<lootgroup # opening tag
(?:(?!</lootgroup>).) # Tempered greedy token, make sure we don't encounter closing tag
\bschematics\b # literally
(?:(?!</lootgroup>).) # Tempered greedy token, make sure we don't encounter closing tag
</lootgroup> # closing tag
Screenshot:
CodePudding user response:
The below code works for me ....
Find:^\s*<loot(.*\n.*){0,2}schem[\S\s] ?group>
Replace with:nothing

