Replacing text using regular expressions
Regular expressions are used to generate the text that will replace the matched text in the Find criteria. You can use regular expressions when finding and replacing text in the Editor view and Translation Memories view.
About this task
You can use regular expressions in your search criteria. For example, you could search segments that contain email addresses in the text. Regular expressions are used to search text for all occurrences of a particular sequence, or pattern, of characters. They differ from standard search tools because they use special metacharacters. Metacharacters enable you to create a single regular expression that will find all occurrences of a basic pattern and also specific variations of the pattern.
This tool is for users who know how to create and use regular expressions.
Trados Studio uses the .Net syntax for regular expressions. For more information on how to use regular expressions, see http://www.regular-expressions.info/reference.html.
Procedure
- Go to the Projects view and select the project you want to work on.
- Go to the Files view and double-click the file you want to work on.
- Go to the Home tab, and in the Editing group, select Replace.
- Select Use Regular Expressions and make your changes.
Example: text replacement using regular expressions
Use this regular expression in the Replace box:
- '$1' field
It changes the sentence order of the matched sentences to the following where XYZ represents the field name:
- "The 'XYZ' field is displayed."
For example, this changes the order of the matched sentences to the following:
- "The Address field is displayed."
- "The Name field is displayed."
- "The Email field is displayed."
For more information on how to use substitution regular expressions, see for example http://msdn.microsoft.com/en-us/library/ewy2t5e0.aspx.