I have the following line in a file:
“A”,",",",“B”,“C"
I use a Text Replace action to replace ALL instances of ,”, with ,"",
The result that I would expect would be
“A”,"","","",“B”,“C"
What seems to happen in Automise is that the first instance is evaluated, but then the cursor is past the second comma so the second instance is not evaluated. Then, since the second instance is not evaluated, the third instance IS found:
“A”,”",","",“B”,"C"
Is this expected behavior? When I tell the Text Replace to Find/Replace ALL instances, I expect that everywhere in the line that the pattern is found, it will be replaced. That is not happening here.
What your seeing is standard behaviour for find and replace. Text that is replaced is not used in testing for another replacement.
For example if we have the text “abbabbabb” and replace “ab” with “a” the expected output would be “ababab”. If the text replace was to take into account the whole string after a replacement was made, we would end up with “aaa”.
Below is the workings of the string replace process;
Text | Result | Match |
“A”,",",",“B”,“C” | ||
,",",",“B”,“C” | “A” | false |
“,”,“B”,“C” | “A”,"", | true |
“,“B”,“C” | “A”,”"," | false |
“B”,“C” | “A”,"",","", | true |
“A”,"",","",“B”,“C” | false |
To get the result your after I suggest two passes of the replace your using.
That is actually what I ended up doing as a solution - I was not sure that two would cover it, so I keep looping until it finds no matches.