Replace once in a line + add once

Get help with installation and running here.

Moderators: DataMystic Support, Moderators

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

Replace once in a line + add once

Postby barraba » Tue Sep 07, 2010 12:56 pm

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: 2138
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: Replace once in a line + add once

Postby DataMystic Support » Mon Sep 13, 2010 11:04 am

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
Regards,

Simon Carter, http://DataMystic.com/forums/index.php
http://PredictBGL.com - Insulin dose calculator for Type 1 diabetes
http://DownloadPipe.com - 250,000 free software downloads
http://DetachPipe.com - send huge email attachments


Return to “TextPipe Tips and Tricks, Questions and Support”

Who is online

Users browsing this forum: Majestic-12 [Bot] and 1 guest