A full description of regular expressions is outside the scope of this document. For more information see, for example:
SDL Trados Studio uses the same regular expression rules for file name specification that it uses for examining the structure of a text document. These are the .NET set of regular expressions from Microsoft.
[a-z].*[0-9]\.doc
This regular expression describes any name that starts with a lower case letter, ends with a digit, and has .doc as a file name extension.
For this example, assume you want to specify the structure of a regular expression text file, and translate only text that is marked as comment text, as in the table below. Complete the Regular Expression Text Files > Structure patterns dialog box as follows:
Text to be translated |
Example Settings |
Starts with // and ends at the end of line |
Opening pattern: // Closing pattern: $ Clear Multiline Note that you need to provide a closing pattern (even though Multiline is clear). |
Starts with /*, and ends with */, which can be the same or another line. |
Opening pattern: /\* Closing pattern: \*/ Select Multiline |
For this example, assume you want to treat all email addresses as placeholder tags.
An example email address is:
John.brown_27@gmail.co.uk
A possible (not perfect) expression for an email address is:
<word characters, hyphens and periods>@<word characters, hyphens and periods>
A simple corresponding regular expression is:
[\w\-\.]+@[\w\-\.]+
To use this expression as a placeholder, in the Regular Expression Text Files > Inline patterns dialog box, select Add Rule. The Add inline rule dialog box is displayed. Complete this dialog as follows:
Box |
Example Settings |
Rule type |
Select Placeholder |
Rule |
Opening: [\w\-\.]+@[\w\-\.]+ |
Properties |
Click Advanced. In Placeholder behavior select include with text. |
When the file is opened for translation, any email address in the file is treated as a placeholder tag that is displayed in the translation window.
For this example, assume you want to use <b> and </b> as a tag pair to show bold text.
In the Regular Expression Text Files > Inline patterns dialog box, select Add Rule. The Add inline rule dialog box is displayed. Complete this dialog as follows:
Box |
Example Settings |
Rule type |
Select Tag pair |
Rule |
Opening: <b> Closing: </b> |
Properties |
Click Translate and select always translatable Click Edit. The Formatting dialog is displayed. Click style bold and select activate. |
When the file is opened for translation, any occurrence of <b> ... </b> in the file is treated as a tag pair, and the text inside the tags is displayed in bold.
Regular Expression Text > Structure Patterns
Regular Expression Text > Inline Patterns
About Specifying the Structure of Text Files