Tapatalk

Search for missing tag between two other tags

Search for missing tag between two other tags

2
NewbieNewbie
2

    Jul 18, 2018#1

    First post here.  Using UE 25.10.0.50 on Windows 10 x64 (1803 build).

    I have an XML file with multiple <Event ID> and closing </Event> tags.  Between these tags there should be a <Modified> tag, but in some instances it's missing.

    The <Modified> tag doesn't have a specific position - it could come between 1-10 lines after <Event ID> and 1-10 lines before </Event>.

    How can I search for the missing <Modified> tags?

    Thanks in advance,
    LQH

    19176
    MasterMaster
    19176

      Jul 18, 2018#2

      Hi luoqianhe

      this should solve your problem:
      (?s)<(?<TAG>Event ID)\b[^>]*+>(?>(?:(?!<\k<TAG>\b)(?!</\k<TAG>\b)(?!<Modified\b).)++)*+</\k<TAG>>

      You can find more information here: Which RegExp to find a block of several lines, thanks to criteria relative to first and last line of the block

      BR, Fleggy

      EDIT: sorry, the string ID should not be a part of the tag name. Here the correct and simpler search string
      (?s)<(?<TAG>Event) ID\b[^>]*+>(?:(?!<\k<TAG>\b)(?!</\k<TAG>\b)(?!<Modified\b).)++</\k<TAG>>

      2
      NewbieNewbie
      2

        Jul 19, 2018#3

        Thanks, fleggy!

        LQH