-3

I have the following string:

<SomeXmlProperty att="abc" 
att2="def"
att3="ghi"/>
<SomeXmlProperty att4="jkl" 
att5="mno"
att6="pqr"><SomeXmlProperty>
<SomeXmlProperty att="stu" 
att3="vwx"
att6="yz"   
/>

I am needing to match the elements with self closing tags. I have tried using both <SomeXmlProperty((.|\n|\r)*)\/> and <SomeXmlProperty((.|\n|\r)*?)\/> which get close but the middle element still gets matched. What am I doing wrong here?

Woody
  • 1,677
  • 7
  • 26
  • 32

1 Answers1

-1

You can use a character class that excludes <s instead to avoid matching multiple tags:

<SomeXmlProperty[^<]*\/>

Demo: https://regex101.com/r/VEyVg1/1

blhsing
  • 91,368
  • 6
  • 71
  • 106