Page 1 of 1

Replace once in a line + add once

Posted: Tue Sep 07, 2010 12:56 pm
by barraba
I think this kind of work cannot be done with standart functions, if not - please, help me out!

I have file with text lines split by ENTER

i need to:

Parse line by line
Find inline "text1" replace it with "text2" , if once replaced in line find next "text1" in this line and replace with "text3" and so on to "text4"
If "text1" found only 2 times, add "text4" to the end of the line
If there is no "text1" in the line, add "text2", "text3", "text4" to the end of the line

please help .

Re: Replace once in a line + add once

Posted: Mon Sep 13, 2010 11:04 am
by DataMystic Support
Inside a 'Restrict to each line in turn' filter,
add 3 search and replaces, each with the option 'Replace Once Only' checked.
test1->test2
test1->test3
test1->test4

Then use a separate restrict to lines NOT matching 'text1', and inside it, add a 'Add Right Margin' filter with text of
text4