How to use Regex in Trados Studio

What is Regex?

A Regular Expression (or Regex) is a pattern (or filter) that describes a set of strings that matches the pattern. In other words, a regex accepts a certain set of strings and rejects the rest. 

It is often used in computer science. In Trados Studio, we can use Regex to search, identify, and replace certain words or phrases(potential errors) in a long real-world document to enhance translation efficiency. In other words, translators do not have to do the before mentioned work manually, which saves much time and improves accuracy. For example, In America, the date is formally written in month/day/year form, while in Germany, the date format is day/month/year. If dates appear in a text repeatedly and are translated in wrong format, translators can replace them easily with the help of Regex.

I am going to use four examples to illustrate the use of Regex.

1. QA Checker: Ellipsis check

I translated a text from Chinese to English. The Chinese ellipsis consists of 6 points, while the English one has only 3 points. I am sure that the source text does not have any grammatical problems. So I decided only to check the target text. Once a Chinese ellipsis exits in the English text, it will trigger an error.

My QA Checker setting:

My example:

When the Chinese ellipsis was found in the target text, an error was generated. It is easy for editors to locate and correct.

2. QA Checker: address formatting check

I translated a text from German to English. In German, the address format is street name + house number, zip code, city, while in English is house number + street, city and zip code.

I write “in” to identify the address behind this preposition. \s is a space. [A-Za-z] St means the street name, \d is house number, d{5} is zip code and again city name. This is the German address formatting. If the same formatting is checked in English, it should be warned.

3. QA Checker: telephone number check

I translated a text from German to English. There is no space in German telephone number, while English telephone number has a“-” between every 3 digits.

I divided telephone number into three groups so that they can be detected by QA Checker. If there is no “-” in between, I get a warning.

4. Find and Replace: date formatting

I translated a text from German to English. The date format in German is DD/MM/Year, while in English, it is MM/DD/Year. (\d{2}) represents a group with 2 digits and (\d{4}) with 4 digits. “$ number” includes the last substring matched by the capturing group that is identified by number, where number is a decimal value, in the replacement string.

Three dates should be replaced in my text, which are sentence 2, 3 and 9. I have replaced sentence 9, while sentence 2 and 3 still remain the German format.

Read more about Trados Studio:

Using Trados Studio to complete a CAT project

Leave a Reply

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