Application Examples for Regular Expressions

Regular expressions do not always need to be complicated and consist of various letters, numbers, and special characters. For example, a simple regular expression might solely consist of letters, which you can enter as a character string in the respective template. In this way, you can e.g. convert product names to protected placeables.

In the following you can find examples showing how regular expressions are employed when using document settings templates in Across.

Example 1

Starting point

You would like to translate a Word document in the DOC format in Across which contains a table with cells consisting only of numbers. Additionally, the cells can contain plus or minus signs, fractional digits, and separators such as -1.234 or +3,456.56.

Example table:

regulaere-ausdruecke_bsp1

Task outline

As it is certain that numbers need not be adjusted in the target language, the cells described above should be "locked" in crossDesk: in this way these cells will be visible, but not editable.

Representation with regular expressions

The following string displays the numbers as regular expressions:

^[+-]*[0-9,.]+$

The string is built up as follows: It stands for any digits (0-9) which can be separated by a comma or a full stop (,.), and which can occur any number of times but at least once (+) and can take the signs + or - ([+-]), but not necessarily (*). The operators ^ (beginning of a paragraph or cell) and $ (end of paragraph or cell) ensure that only paragraphs or cells made up of the respective numbers are found and locked.

Put into practice in Across

Select a Word template in the system settings via Tools > System Settings > Document Settings > Word 2000-2003 or create a new one by clicking the button New. Then click Add to insert the regular expression into the template.

Enter the string of the regular expression into the input field Name, select Context as format and Locked as type.

Click ... to check whether the regular expression has been formulated correctly. On the one hand, you can check whether the syntax of the regular expression is correct. On the other hand, you can enter sample strings to check whether the regular expression correctly represents these sample strings.

Click OK. Now check in the Word document and employ the Word template when creating the project.

Result in Across

The cells will be displayed in crossDesk but will be "locked" and cannot be edited.

Compare it to a similar document that has been checked in without the template. Correspondingly, the cells are displayed and can or have to be edited.

Example 2

Starting point

You would like to translate an Excel sheet in Across which contains cells that are exclusively made up of figures, order and article numbers etc. such as 123-456 or 12-3456-7890.

Sample document:

regulaere-ausdruecke_bsp2

Task outline

As it is certain that numbers need not be adjusted in the target language, the cells described above should not be displayed for translation in crossDesk.

Representation with regular expressions

The following string represents the figures and numbers as regular expressions:

^[0-9\-]+$

The character string is built up as follows: it stands for any figures (0-9), that can be separated by a hyphen (\-) and may occur any number of times, but at least once (+). The operators ^ (beginning of a paragraph or cell) and $ (end of paragraph or cell) ensure that only paragraphs or cells that consist exclusively of the respective figures or numbers are found and hidden.

Put into practice in Across

Select an Excel template in the system settings via Tools > System Settings > Document Settings > Excel 2000-2003 or create a new one by clicking the button New. Then click Add to insert the regular expression into the template.

Select Context as filter and enter the string of the regular expression into the input field. Then select the option Hidden as you do not want the corresponding cells to be visible in crossDesk and click OK.

Now check in the Excel file and employ the Excel template when creating the project.

Result in Across

As intended, the corresponding cells will not be displayed in crossDesk and consequently cannot be edited.

Compare it to a similar document that has been checked in without the Excel template. Correspondingly, the cells are visible.