RegEx: Unleash your pattern-nal instincts!

We previously discussed the enormously powerful Search & Replace feature of Cattitude, which allows you to search and replace terms and sentences in multiple translation memories and terminology databases simultaneously in one go. Now this feature has become even more powerful with the introduction of RegEx, a search pattern language that allows you to introduce wild cards in your searches. Without further ado, let’s go to a real-life scenario.

Today a client asked me to change the Dutch translation of the word Gain from Verdien (Earn) into Krijg (Get) when it referred to Gaining stacks, as I had not been entirely consistent (hey, I’m only human)!

By defining the old target as Verdien (Earn), the new target as Krijg (Get) and defining the source as Gain (change Verdien (Earn) into Krijg (Get) if the source contains the word Gain), I got the following:

Looks good, right? Until I started scrolling down.

We now see several instances that do not contain the word stacks, in which Gain should stay as Verdien (Earn), as these are actual calls to action that sound very awkward in Dutch if they use the verb Krijg (Get) instead. The imperative of Get in Dutch just sounds really funny.

Normally I could just opt for searching and replacing Verdien stapels (Earn stacks), but as you can see, the word stacks is surrounded by tags that make it stand out in the text by giving it another color or font weight. Replacing Verdien ◀️0▶️stapels is not a good solution either, as the number in the tag can vary…

Kitty to the rescue

So how to I tell my CAT tool to only update Gain if it refers to gaining stacks and not when used in general calls of action? The normal answer would be: you can’t. In most cases you need to do dozens of search and replace operations or worse: go over all strings manually.

In Cattitude however there’s a way using RegEx. RegEx, short for Regular Expression, is a sequence of characters that forms a search pattern. This pattern is then used in a search operation, usually within text-based data, to identify specific strings or sets of characters. They can be simple, such as searching for the word “apple,” or very complex, finding patterns in text like email addresses, URLs, or specific formatting.

Cattitude is one of the very few tools that supports RegEx for updating your translations memories and terminology databases (in one go). Here I define the Regex needed:

Find: Verdien\s◀️(\d)▶️\sstapel

\s stands for a space. \d stands for a digit. () around \d means: let’s call this digit a group. As there’s only one group in this string, this group is now referred to as group 1.

Replace with: Krijg ◀️$1▶️ stapel

$1 here is a reference to the previously defined group 1 (the random digit).

Only if source contains: Gain

So basically this means: find Verdien ◀️x▶️ stapel and replace it with Krijg ◀️x▶️ stapel, and meanwhile preserve the number x, whatever it is, but only if the source text contains the word Gain.

Cattitude does its work and shows a preview of the result. Is this really what I want? Note that Cattitude’s Search and Replace feature is incredibly powerful, but that this also means that mistakes can be very costly, as it will plough through your entire database and do what you told it to do. So checking this preview is very important.

All looks good! Let’s go.

As you can see, all replacements have been made, and no calls to actions were touched. The operation only applied to strings containing the word stacks.

Though this is advanced use of Cattitude, I hope this shows how incredibly powerful this tool can be when used properly. An operation which would normally have cost hours was done in less than one minute. That is some serious kitty power.

Cute little red kitten sleeps on fur white blanket

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.