Search and replace with RegEx

Bear in mind that, be default, Regular Expressions are case sensitive. That means that if you, for example, construct a Regex that can find the word and in a text, it will not find the word And. It is possible to create Regexes that will find words written in different cases. For that, you should study one of the resources shown at the bottom of this page.

What are Regular Expressions

Regular Expressions, or RegEx, are strings of text that can be used to specify a search pattern. They are like the wild cards that you may already have used, but much more powerful. By using a correctly constructed Regular Expression you can find things in a large block of text that would take many separate search operations to find using a normal search function, even one that support wild cards.

Regular Expressions have been supported by Déjà Vu for some time, but only in certain places: e.g., they can be used with some filters to replace untranslatable text with tags to ensure that the text is not inadvertently modified by the translator.

Now, Déjà Vu X3 lets you use Regular Expressions in the Search and Replace dialogs of projects, Translation Memories and Termbases. With the use of Regular Expressions, the Search and Replace function in Déjà Vu X3 will become far more powerful than it was before.

How to use Regular Expressions

How to use Regular Expressions to search in Déjà Vu X3

Using regular expressions to search inside a project, a Translation Memory or a Termbase is very easy. Déjà Vu X3 now has a checkbox labelled Use regular expressions in the Search and Replace dialog that you can check to enable to use of Regular Expressions. Leaving this checkbox unchecked will result in Déjà Vu X3 performing a normal search.

The Find dialog

In a project, the Find dialog looks like this:

In a Translation Memory and a Termbase it looks like this:

The Replace dialog

The Replace dialog in a project looks like this:

In a Translation Memory it looks like this:

And in a Termbase it looks like this:

How to construct a regular expression

Regular Expressions are far more powerful than simple wild cards, but they are also more difficult to learn. To help you get started, we will provide several sample Regular Expressions here that you can use to find certain things.

Quick reference for RegEx

Here is a list of the basic operators you can use to construct regular expressions. Click on any Regular Expression in the table to see examples of what it doesnote:

Regular expression Description Example
abc The letters abc. If you type a few letters, letters a to z, or A to Z, those same letters will be matched.

Here you will see examples of how to use the regular expressions described in this table. The examples will show what text a regular expression will find by showing you some sample text, and highlighting the text the regular expressions matches like this.

a? Zero or one of a
a* Zero or more of a
a+ One or more of a
a{3} Exactly 3 of a
a{3,} 3 or more of a
a{3,6} Between 3 and 6 of a
. Any single character
\d Any digit
\D Any non-digit
\s Any whitespace character
\S Any non-whitespace character
\w Any word character (letter, number, underscore)
\W Any non-word character
[] You can use the square brackets to specify single letters or digits you want to look for. You can also use them to specify ranges of letters or digits to look for, which is what makes them powerful.
^ Start of line
$ End of line
(...) Capture everything enclosed
a|b a or b

To learn more about Regular Expressions

There is much more to learn about Regular Expressions. There are entire books devoted to the subject that you can purchase if you are so inclined. However, there is also much information available free of charge on the web; for example, here.

You can find an effective tutorial here. This will show the basics of Regex, and allow you experiment using basic Regexes, and later on more complex ones.

There are also RegEx testers available online that can help you construct a Regular Expression that will find what you need. These testers can be invaluable in learning how to construct Regular Expressions, and in making sure that the more complex RegEx strings you create will do exactly what you need. Following are several RegEx testers we have used ourselves (though there are many others that are likely just as good):

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request


Powered by Zendesk