Remove irregular text between delimiters leaving some text.

General discussions about Advanced Find and Replace
Post Reply
RTenebruso
Posts: 4
Joined: Thu Sep 28, 2006 4:37 am

Remove irregular text between delimiters leaving some text.

Post by RTenebruso »

I am trying (without success) to delete all text other than the tildes ~ after LastName and up to ZZEND

So

FirstName~LastName~Japanese~Jap-X~5~No Body~S1~C1~COMMENT~Barghout~Fullname~ZZEND

Would be rewritten as

FirstName~LastName~Japanese~~~~~~~~~ZZEND

FirstName and LastName are all different and of different length.

I have have a bunch of these to do.

Thank you for creating AFR (it has saved me hundreds of hours) and for any help you extend on this question.

Abacre
Site Admin
Posts: 1223
Joined: Mon Jan 31, 2005 5:32 pm

Post by Abacre »

Go to main menu - Action - Options - Batch Replace
uncheck "Modifier S"

Go to Batch replace tab, check on "Use regular expressions".
Put into the grid, search for:
(.+)~(.+)~Japanese~.+~.+~.+~.+~.+~.+~.+~.+~ZZEND

Replace with:
$1~$2~Japanese~~~~~~~~~ZZEND

Explanations:
.+ means any non empty text.
with () with put found text into $1, then into $2. We use it to store
first name and last name.

Should also Japanese be variable text?
Then you should use:

Search for:
(.+)~(.+)~(.+)~.+~.+~.+~.+~.+~.+~.+~.+~ZZEND

Replace with:
$1~$2~$3~~~~~~~~~ZZEND

That's all I verified it works perfectly.
Kind regards,
Abacre Limited
http://www.abacre.com
support@abacre.com

RTenebruso
Posts: 4
Joined: Thu Sep 28, 2006 4:37 am

Thank you.

Post by RTenebruso »

Thank so much. It does work perfectly. It is elegant. Thank you for the explaination, too. AFR is so powerful and it is enjoyable to learn how to take advantage of some of what you have built into it.

Ray

Post Reply