How to search and replace from right to left?

When you use the Search and Replace System Clipboard action, the search is performed from left to right.

Is it possible to create a way to reverse this direction? So that the search starts at the end of paragraph (segment)?

Here's my problem: I have a macro that sorts the lines of a two-column glossary by the lengt of the terms in the first column. I then use this sorted glossary for Search and replace actions.

This doesn't give me the result I was hoping for. For example:

Paragraph:

Ensure that all protective packaging materials have been removed and that the packaging machine is positioned horizontally on the factory floor.

Glossary lines:

protective packaging	beschermende verpakking
packaging materials	verpakkingsmaterialen
protective	beschermende
packaging	verpakking
materials	materialen

Result of Search and Replace from LTR:

Ensure that all beschermende verpakking materialen have been removed and that the packaging machine is positioned horizontally on the factory floor.

Whereas I want:

Ensure that all beschermende verpakkingsmaterialen have been removed and that the packaging machine is positioned horizontally on the factory floor.

I can see that if I search from RTL, the first hit would be: packaging materials. Then the next hit would be: protective.

How can I solve this?

Edit: I could reverse the paragraph and the search string.

Direction of search doesn't matter -- it's the order in which you run through your search terms that is important. You'll need to either look for packaging materials before looking for protective packaging or add an earlier entry for protective packaging materials.

As proof -- you can reverse the search direction by

  1. Reversing your target string
  2. Reversing your glossary entry
  3. Do the S'n'R
  4. Reverse the modified target string

...giving:

Glossary Reverse Search.kmmacros (7.9 KB)

Image

...which you'll see suffers from the same problem as a "normal" search.

1 Like

Thank you Nige!

So I'll have to think about how to get the source terms in the right order. Not sure if this is possible at all. It's the same problem that @ComplexPoint already mentioned.

Edit: And thank you for showing the rev command. As with all your replies: I learn a lot from you. :pray:t2: