2

Conditions:

  • it has to be between <tag> and </tag>
  • between those tags, it has to have both <b> and {1}

Placement of <b> and {1} is random (but it's always between 2 tags).

If conditions are met, select only <b>.

I'm spending half day for that, and can't get it working, haha. Working on regex101.

This is example:

<tag><b>{1}test</tag> 
<tag><b>test</tag>

As far as my knowledge goes, the rough concept is:

(?! ( (condition1)|(condition2) ) (select word) )

Meaning both condition1 and condition2 have to be met to select (select word). Is there something wrong..?

EDIT: Practical sample, from game files:

<Entry>
      <DefaultText>&lt;line-height=100%&gt;{0}% Damage and Healing, {1} &lt;link="glossary://GlossaryEntry_Fortitude"&gt;&lt;b&gt;Fortitude&lt;/b&gt;&lt;space=0.7em&gt;&lt;#f9d968&gt;&lt;sprite="Inline" name="cs_fortitude" tint=1&gt;&lt;/color&gt;&lt;/link&gt;&lt;/line-height&gt;</DefaultText>

</Entry>
Casimir et Hippolyte
  • 88,009
  • 5
  • 94
  • 125

1 Answers1

0

Check on the next regex <tag>(?=(?:(?!<\/?tag>).)*?<b>)(?=(?:(?!<\/?tag>).)*?\{1})(?:(?!<\/?tag>).)*<\/tag>.

To try the regex online and get an explanation, please click here.

Andrei Odegov
  • 2,925
  • 2
  • 15
  • 21