1

I am trying to find XML tag which has a attribute which does contain a certain value in their string. For example you have this XML:

<situation xsi:type="..." id="PK_1243f_TESTING_093891">
        .....
</situation>

In this example you see that the id has 'TESTING' in it. But there are also situations without this in their id like this:

<situation xsi:type="..." id="PK_1932z_093716">
        .....
</situation>

Which can be found by this regex:

<situation xsi:type="([^\"]*)\" id="((?!TESTING).)*"(?:(?!</situation>).)+</situation>

What changes need to be made in the regex above to find the situation with 'TESTING' in their id.

1 Answer 1

3
  • Ctrl+F
  • Find what: <situation xsi:type="([^"]*)" id="[^"]*TESTING[^"]*"(?:(?!</situation>).)+</situation>
  • CHECK Match case
  • CHECK Wrap around
  • CHECK Regular expression
  • CHECK . matches newline
  • Find All in Current Document

Explanation:

<situation xsi:type="           # literally
([^"]*)                         # group 1, 0 or more non "
"                               # quote
id="                            # literally
[^"]*                           # 0 or more non "
TESTING                         # literally
[^"]*                           # 0 or more non "
"                               # quote
(?:(?!</situation>).)+          # 1 or more any character, but never </situation>
</situation>                    # end tag

Screenshot:

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.