Replace once in a line + add once

Get help with installation and running here.

Moderators: DataMystic Support, Moderators, DataMystic Support, Moderators, DataMystic Support, Moderators

Post Reply
barraba
Posts: 1
Joined: Tue Sep 07, 2010 12:46 pm

Replace once in a line + add once

Post 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 .
User avatar
DataMystic Support
Site Admin
Posts: 2227
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: Replace once in a line + add once

Post 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
Post Reply