I'm trying to come up with a regex that will match the entirety of the tag that has "ThisIsImportant" (including the tags themselves), without matching either of the other ones:
<tag>
<random attribute="ThisIsNotImportant" />
</tag>
<tag>
<random attribute="ThisIsImportant" />
</tag>
<tag>
<random attribute="ThisIsAlsoNotImportant" />
</tag>
So far I've got "<tag>.*?</tag>", but I don't know how to make it so that I only match the one with "ThisIsImportant". Can anyone provide some help?
Thanks in advance.
EDIT: For clarity, I want to match the entirety of "<tag><random attribute="ThisIsImportant" /></tag>".
I am trying to do this in Bash using the perl executable, and am avoiding something like xmlstarlet because the environments I need to run the script on does not have access to this application.
tags themselves? Are you looking for just the tag that has that attribute value, or are you looking for a closing tag, and all between as well ?