0
I need a hand with Regex again! I need to edit an xml file and insert after a certain information a sequence of instructions. But I can’t select all the information I need. I need to select the following information:
<testerconfirmation title="Tester Confirmation " passedbutton="yes" timeoutresult="failed">REQUIREMENT SPECTED
After T_Checkdisplay (5 seconds), the indication OIL CHANGE REQUEST V3 must be activated according to indications characteristics during 5 seconds.
Press YES to continue.</testerconfirmation>
In the case above I need to select all the information that is inside the tag and contains the information OIL CHANGE REQUEST V3. After finding this information I need to insert some lines of code after the selected information. These are the lines I want to add:
<capltestfunction title="RUN INSPECTION" name="RunInspection">
<caplparam type="string" name="InspName" />
</capltestfunction>
<capltestfunction title="ADD IMAGE TO REPORT" name="AddInspectionImageToReport" />
<capltestfunction title="CHECK ST_F-4" name="CheckStepResultCamera">
<caplparam type="string" name="StepName">ST_F-4</caplparam>
<caplparam type="float" name="ExpVal">1</caplparam>
<caplparam type="float" name="ToleranceUnits" />
<caplparam type="float" name="TolerancePercent" />
</capltestfunction>
<capltestfunction title="CHECK ICON_F-4" name="CheckStepResultCamera">
<caplparam type="string" name="StepName">ICON_F-4</caplparam>
<caplparam type="float" name="ExpVal">1</caplparam>
<caplparam type="float" name="ToleranceUnits" />
<caplparam type="float" name="TolerancePercent" />
</capltestfunction>
<capltestfunction title="CHECK MESSAGE PB058_1" name="CheckStepResultCameraText">
<caplparam type="string" name="StepName">TM_PB058_1</caplparam>
<caplparam type="string" name="ExpVal">OilChange</caplparam>
<caplparam type="int" name="ContainsExpVal" />
<caplparam type="int" name="TolerateSimilarChars">1</caplparam>
</capltestfunction>
<capltestfunction title="CHECK MESSAGE PB058_2" name="CheckStepResultCameraText">
<caplparam type="string" name="StepName">TM_PB058_2</caplparam>
<caplparam type="string" name="ExpVal">Required</caplparam>
<caplparam type="int" name="ContainsExpVal" />
<caplparam type="int" name="TolerateSimilarChars">1</caplparam>
</capltestfunction>
Then the code as follows:
<testerconfirmation title="Tester Confirmation " passedbutton="yes" timeoutresult="failed">REQUIREMENT SPECTED
After T_Checkdisplay (5 seconds), the indication OIL CHANGE REQUEST V3 must be activated according to indications characteristics during 5 seconds.
Press YES to continue.</testerconfirmation>
<capltestfunction title="RUN INSPECTION" name="RunInspection">
<caplparam type="string" name="InspName" />
</capltestfunction>
<capltestfunction title="ADD IMAGE TO REPORT" name="AddInspectionImageToReport" />
<capltestfunction title="CHECK ST_F-4" name="CheckStepResultCamera">
<caplparam type="string" name="StepName">ST_F-4</caplparam>
<caplparam type="float" name="ExpVal">1</caplparam>
<caplparam type="float" name="ToleranceUnits" />
<caplparam type="float" name="TolerancePercent" />
</capltestfunction>
<capltestfunction title="CHECK ICON_F-4" name="CheckStepResultCamera">
<caplparam type="string" name="StepName">ICON_F-4</caplparam>
<caplparam type="float" name="ExpVal">1</caplparam>
<caplparam type="float" name="ToleranceUnits" />
<caplparam type="float" name="TolerancePercent" />
</capltestfunction>
<capltestfunction title="CHECK MESSAGE PB058_1" name="CheckStepResultCameraText">
<caplparam type="string" name="StepName">TM_PB058_1</caplparam>
<caplparam type="string" name="ExpVal">OilChange</caplparam>
<caplparam type="int" name="ContainsExpVal" />
<caplparam type="int" name="TolerateSimilarChars">1</caplparam>
</capltestfunction>
<capltestfunction title="CHECK MESSAGE PB058_2" name="CheckStepResultCameraText">
<caplparam type="string" name="StepName">TM_PB058_2</caplparam>
<caplparam type="string" name="ExpVal">Required</caplparam>
<caplparam type="int" name="ContainsExpVal" />
<caplparam type="int" name="TolerateSimilarChars">1</caplparam>
</capltestfunction>
I’m using Notepad ++, but if you have any solutions or experience with any other Sw that makes it easy to work with code please leave a comment that will also be welcome! Thank you all!
I don’t understand what you need to select and what you need to replace...
– KhaosDoctor
Hello @Khaosdoctor, sorry if the explanation was not clear. In fact I need to find the first part of the code (<testerconfirmation up to </testerconfirmation>) and add after this information the second part of the code (which starts in <capltestfunction title="RUN INSPECTION" name="Runinspection">). I hope it helped! Thank you!
– Diego Sanches Garcia
@Khaosdoctor see if he’s improved?
– Diego Sanches Garcia
Look, I believe that that will help you, but you’ll have to do some manual work picking up the whole group and replacing it with yourself, plus your new string at the bottom line
– KhaosDoctor
@Khaosdoctor, I created this regex ( s s s s s s s s s<testerconfirmation.\n.REMOTE START SHUT DOWN V3.\n.\n. *</testerconfirmation>) to select the information I need, but when I replace the selected information ($1+ the rest of the text) it does not replace correctly.
– Diego Sanches Garcia