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 » Thu Sep 28, 2006 10:41 pm

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: 1198
Joined: Mon Jan 31, 2005 5:32 pm
Contact:

Post by Abacre » Fri Sep 29, 2006 9:16 am

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 » Sat Sep 30, 2006 5:38 pm

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

Who is online

Users browsing this forum: No registered users and 3 guests