Documentation Center

Examples - Structuring text files (regular expression delimited text files)

Examples of using regular expressions to define text files that are delimited by regular expression patterns.

Example: Simple file name specification

The regular expression [ a-z].*[0-9]\.txt describes any name that starts with a lower case letter and ends with a digit followed by the letters *.txt

Example: Structure in a Regular Expression Delimited text file

To specify the structure of a Regular Expression Delimited text file, and to specify that the processor translates only text that is marked as comment text, set the Text file type settings for Document structure in accordance with the following:
Text to be translatedExample 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

Example: Regular Expression Delimited text file - standalone (placeholder) tag

To treat all email addresses as standalone (placeholder) tags. An example email address is:John.brown_27@gmail.co.uk

One possible expression for an email address is:

word characters, hyphens and periods, @ character, word characters, hyphens and periods

A simple corresponding regular expression is:

[\w\-\.]+@[\w\-\.]+

To use this expression to specify a standalone tag, go to File > Options > File Types > Text > Inline Patterns and select Add Rule.

Complete the Add inline rule dialog as follows:

BoxExample settings
Rule type

Select Placeholder

Rule

Opening: [\w\-\.]+@[\w\-\.]+

Properties

Click Advanced. Select include with text in Placeholder behavior.

When the file is opened for translation, any email address in the file is treated as a standalone tag and is displayed in the translation window.

Example: Regular Expression Delimited text file - tag pair

Enable <b> and </b> to be treated as a tag pair that shows bold text. In the Regular Expression Text Files > Inline Patterns dialog box, select Add Rule. In the Add inline rule dialog box, complete the following:
BoxExample settings
Rule type

Select Tag Pair

Rule

Opening: <b>

Closing: </b>

Properties

Click Translate and select always translatable.

Edit the formatting to 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.