Recently upgraded a Cognos reporting environment with over 4000 reports specifications stored in XML. There are certain style functions that have been deprecated and my task is to find them and replace with the current function. My attempt to search for specfic style references is returning more data than desired.
<(style>){1}.*?"np".*?</\1
It is finding all the text shown below (note: the carriage returns were added for readiability, they don’t exist in the source XML file).
I really only want to find the last line (underlined). It starts correctly, finding the first style tag, but I would like it to fail if it finds a closing “/style” tag, before it finds the “refStyle” , I was hoping the {1} would limit the result to just include the reference to style> only once.
Any suggestions on how to fix this Regular expression will be appreciated.
<style><CSS value="border-bottom:1pt solid black;border-right:1pt solid black"/></style>
</tableCell><tableCell><contents><textItem><dataSource><staticValue>Sum:</staticValue></dataSource></textItem></contents>
<style><CSS value="background-color:white;font-family:Arial;font-size:10pt;font-weight:bold;vertical-align:top;text-align:center;width:90px;height:35px;padding-top:5px;padding-bottom:5px;border:1pt solid black"/></style>
</tableCell></tableCells></tableRow><tableRow><tableCells><tableCell><contents><textItem><dataSource><staticValue>Sum:</staticValue></dataSource></textItem></contents>
<style><CSS value="background-color:white;font-family:Arial;font-size:10pt;font-weight:bold;vertical-align:middle;text-align:left;width:90px;height:35px;padding-top:5px;padding-bottom:5px;padding-left:3px;border:1pt solid black"/></style>
</tableCell><tableCell><contents/>
<style><CSS value="width:90px;height:25px;border:1pt solid black"/></style>
</tableCell></tableCells></tableRow></tableRows>
<style><CSS value="border-collapse:collapse;text-align:center"/><defaultStyles><defaultStyle refStyle="tb"/></defaultStyles></style>
<conditionalStyles><conditionalStyleCases refVariable="Conditonalblock2 - Var"><conditionalStyle refVariableValue="1"/></conditionalStyleCases><conditionalStyleDefault><CSS value="display:none"/></conditionalStyleDefault></conditionalStyles></table><table><tableRows><tableRow><tableCells><tableCell><contents><textItem><dataSource><dataItemValue refDataItem="Assignment"/></dataSource>
<style><defaultStyles><defaultStyle refStyle="np"/></defaultStyles></style>