This should be a simple task. Get the string, make changes to the string and write it to the document. I've tried to make my REGEX's as general as possible so it can capture all instances found in the document.
XML Sample:
Code: Select all
function DeleteEmptyLines ()
{
UltraEdit.perlReOn();
UltraEdit.activeDocument.findReplace.mode=0;
UltraEdit.activeDocument.findReplace.matchCase=false;
UltraEdit.activeDocument.findReplace.matchWord=false;
UltraEdit.activeDocument.findReplace.regExp=true;
UltraEdit.activeDocument.findReplace.searchDown=true;
UltraEdit.activeDocument.findReplace.searchInColumn=false;
UltraEdit.activeDocument.findReplace.preserveCase=false;
UltraEdit.activeDocument.findReplace.replaceAll=true;
UltraEdit.activeDocument.findReplace.replaceInAllOpen=false;
UltraEdit.activeDocument.top();
UltraEdit.activeDocument.findReplace.replace("^(?:[\t ]*(?:\r?\n|\r))+", "");
}
function convertInputTables()
{
//Declare variables
var sInputConditionString = "";
var sStartTabMat= "";
var sReqCond = "";
var Regex = "";
var sMark = "****************************************************************************************************";
UltraEdit.perlReOn();
UltraEdit.activeDocument.findReplace.mode=0;
UltraEdit.activeDocument.findReplace.matchCase=false;
UltraEdit.activeDocument.findReplace.matchWord=false;
UltraEdit.activeDocument.findReplace.regExp=true;
UltraEdit.activeDocument.findReplace.searchDown=true;
UltraEdit.activeDocument.findReplace.searchInColumn=false;
UltraEdit.activeDocument.findReplace.preserveCase=false;
UltraEdit.activeDocument.findReplace.replaceInAllOpen=false;
UltraEdit.activeDocument.top();
UltraEdit.activeDocument.findReplace.replaceAll=true;
UltraEdit.activeDocument.findReplace.replace('(<tabmat frame=".*?".*?>)', '\r\n$1');
DeleteEmptyLines ();
UltraEdit.activeDocument.top();
while (UltraEdit.activeDocument.findReplace.find('<tabmat frame=".*?".*?>[\s\S]+?Input Conditions[\s\S]+?<emphasis.*?>[\s\S]+?Additional Data:[\s\S]+?<\/tabmat>'))
{
//UltraEdit.activeDocument.cut();
sInputConditionString = UltraEdit.activeDocument.selection;
UltraEdit.activeDocument.cut();
var Regex = /<\/tbody><\/tgroup><\/tabmat>/g;
sRvmEnds = sInputConditionString.replace(Regex, "");
//REplace first match in string
var Regex = /<tabmat(.*?)>([\\s\\S]+?<tbody>)/m;
sInputResult = sRvmEnds.replace(Regex, "<table$1>$2");
// remove remaining <tabmat code from string
Regex = /<tabmat.*?>[\\s\\S]+?<tbody>/g;
sInputResult2 = sInputResult.replace(Regex, "");
// append ending table tags to the end of string
var sAddEnding = sInputResult2 + "<\/tbody><\/tgroup><\/table>";
UltraEdit.activeDocument.write(sAddEnding);
}
}
convertInputTables();
Code: Select all
<para>
<tabmat frame="none" colsep="0" pgwide="0">
<tgroup cols="2" align="left">
<colspec colname="col1" align="left" colwidth="0.99in">
<colspec colname="col2" colwidth="0.78*">
<spanspec namest="col1" nameend="col2" spanname="span1">
<tbody>
<row>
<entry spanname="span1" colsep="0" align="left">
<emphasis type="u">
<?Pub _font TypeSize="10pt" FamName="Arial" Underline="heavy" ScoreSpace="yes"> Input Conditions<?Pub /_font></emphasis>.</entry></row></tbody></tgroup></tabmat>
<tabmat frame="none" colsep="0" pgwide="0">
<tgroup cols="2" align="left">
<colspec colname="col1" align="left" colwidth="1.0in">
<colspec colname="col2" colwidth="0.78*">
<spanspec namest="col1" nameend="col2" spanname="span1">
<tbody>
<row>
<entry spanname="span1" colsep="1" align="left">
<emphasis type="b">Applicability: </emphasis>
<?Pub _hardspace>All</entry></row></tbody></tgroup></tabmat>
<tabmat frame="none" colsep="0" pgwide="0">
<tgroup cols="1">
<colspec colname="col1" colwidth="1.00*">
<tbody>
<row>
<entry>
<emphasis type="b">Required Conditions:</emphasis></entry></row>
<row valign="top">
<entry>
<randlist>
<item>
<emphasis type="u" color="blue">
<xref xrefid="para5.10.1"></emphasis></item></randlist></entry></row></tbody></tgroup></tabmat>
<tabmat frame="none">
<tgroup cols="1">
<colspec colname="col1" colwidth="1.00*">
<tbody>
<row>
<entry>
<emphasis type="b">Personnel Recommended:</emphasis>
<?Pub _hardspace>2 </entry></row>
<row>
<entry>
<randlist>
<item>Technician A: </item>
<item>Technician B: </item></randlist></entry></row></tbody></tgroup></tabmat>
<tabmat frame="none" colsep="0" pgwide="0">
<tgroup cols="2">
<colspec colname="colspec0" align="left">
<colspec colname="colspec1">
<spanspec namest="colspec0" nameend="colspec1" spanname="span1">
<tbody>
<row>
<entry spanname="span1" colsep="1" align="left">
<emphasis type="b">Support Equipment:</emphasis>
<?Pub _hardspace>None</entry></row></tbody></tgroup></tabmat>
<tabmat frame="none" colsep="0" pgwide="0">
<tgroup cols="2">
<colspec colname="colspec0" align="left">
<colspec colname="colspec1">
<spanspec namest="colspec0" nameend="colspec1" spanname="span1">
<tbody>
<row>
<entry spanname="span1" colsep="1" align="left">
<emphasis type="b">Consumables: </emphasis>
<?Pub _hardspace>None</entry></row></tbody></tgroup></tabmat>
<tabmat frame="none" pgwide="0">
<tgroup cols="2">
<colspec colname="col1" colwidth="0.20*">
<colspec colname="col2" colwidth="1.93*">
<spanspec namest="col1" nameend="col2" spanname="span1">
<tbody>
<row>
<entry spanname="span1" colsep="0" align="left">
<emphasis type="b">Safety Conditions:</emphasis>
<?Pub _hardspace>None</entry></row></tbody></tgroup></tabmat>
<tabmat frame="none" colsep="0" pgwide="0">
<tgroup cols="2">
<colspec colname="colspec0" align="left">
<colspec colname="colspec1">
<spanspec namest="colspec0" nameend="colspec1" spanname="span1">
<tbody>
<row>
<entry spanname="span1" colsep="1" align="left">
<emphasis type="b">Additional Data:</emphasis>
<?Pub _hardspace>None</entry></row></tbody></tgroup></tabmat></para>
<subpara2 verstatus="ver">
<title>Removal</title>
<para></para>