Hello,
this is my first post here. I've been using UltraEdit for quite a while but I'm only beginning scripting and I kinda struggle (don't know js either).
However I want to give it a good shot because I think it would help me a lot with work, replacing some software I write in C#.
I'm using Version 17.30.0.1014.
So my problem is the following: I have a xml file that looks like that:
The node scenario may have a name attribute that contains " " (space). I need to replace them with "_".
There are quite a lot of nodes impacted.
The result I look for is the same file with
I've started with that code to find the first occurrence:
If I print the variable reptitl I see the job has been done.
But then I don't know how:
this is my first post here. I've been using UltraEdit for quite a while but I'm only beginning scripting and I kinda struggle (don't know js either).
However I want to give it a good shot because I think it would help me a lot with work, replacing some software I write in C#.
I'm using Version 17.30.0.1014.
So my problem is the following: I have a xml file that looks like that:
Code: Select all
<package name="TEE_TimeArithm_API" version="v1.7" date="2012-04-21">
<initial-state name="Internal_API_Time_Arithm">
<!--Targeted operation: FinalizeContext-->
<scenario name="Invoke_BigIntCmpS32_op strictly lesser than shortval_size 32 bits_two negative values (ce-ef-9e)" destructive="yes">
<req name="BIG_INT_CMP_32" />
...
There are quite a lot of nodes impacted.
The result I look for is the same file with
Code: Select all
<scenario name="Invoke_BigIntCmpS32_op_strictly_lesser_than_shortval_size_32_bits_two_negative_values_(ce-ef-9e)" destructive="yes">
Code: Select all
var regex = "<scenario name=(.*) destructive"; //Perl regular expression to find title string
// Start at the beginning of the file
UltraEdit.activeDocument.top();
// Turn on regular expressions
UltraEdit.activeDocument.findReplace.regExp = true;
// Find it
UltraEdit.activeDocument.findReplace.find(regex);
var reg = new RegExp(" ", "g");
// Load it into a selection
var titl = UltraEdit.activeDocument.selection;
titl = titl.substring(16, titl.lastIndexOf("destructive") - 2);
var reptitl = titl.replace(reg, "_");
But then I don't know how:
- I replace the text inside the original file
- I perform the job on all the occurrences