0

I have XML tag in the following format

<saw:column columnID="c83" xsi:type="saw:regularColumn">            
<saw:displayFormat>
<saw:formatSpec visibility="hidden" suppress="default" interaction="default" wrapText="true"/>
</saw:displayFormat>            
<saw:columnHeading>               
<saw:displayFormat>
<saw:formatSpec interaction="default"/>
</saw:displayFormat>
</saw:columnHeading>
 <saw:columnFormula>
<sawx:expr xsi:type="sawx:sqlExpression">max("Supply Fact"."Count")</sawx:expr></saw:columnFormula>
</saw:column>

I have to replace the data inside the tag <saw:displayFormat></saw:displayFormat>

The tag is present both inside the <saw:column> tag and is also a child of <saw:columnHeading>. I don't wanna replace the displayformat tag inside columnHeading but wanna replace display format tag under saw:column

I tried <saw:displayFormat>.*?</saw:displayFormat>. This fetches all the display format tags .

How to omit the ones inside <saw:columnHeading>?

Toto
  • 89,455
  • 62
  • 89
  • 125
Sukanya Moorthy
  • 109
  • 1
  • 2
  • 10

3 Answers3

1

Demo

(?<!<saw:columnHeading>).<saw:displayFormat>(.*?)<\/saw:displayFormat>.(?!<\/saw:columnHeading>)

It should match your search without being surrounded by columHeading tags. There's a . to match the newline if needed before and after

Tensibai
  • 15,557
  • 1
  • 37
  • 57
0

Though trying to parse xml with regexes is a bad idea, this works for me in Notepad++. It assumes though that there is nothing (including whitespace other than \r\n) between the columnHeading tag and the displayFormat tag.

(?<!<saw:columnHeading>\r\n)<saw:displayFormat>.*?</saw:displayFormat>
asontu
  • 4,548
  • 1
  • 21
  • 29
0
   (?!(?!.*?<saw:columnHeading>))<saw:displayFormat>(.*?)<\/saw:displayFormat>

This should do you work.

See demo.

http://regex101.com/r/cN9bJ4/2

vks
  • 67,027
  • 10
  • 91
  • 124