Using regular expressions in Find and Replace
You can use regular expressions when finding and replacing text in the Editor view and Translation Memories view. To do this, you must first select the Use Regular Expressions option in the Find and Replace dialog box. You can display this dialog box by clicking Home tab > Editing group > Find or
Replace.
Using regular expressions in the Find Criteria
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.
SDL 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.
Using regular expressions in the Replace Criteria
If you used a regular expression as part of the Find criteria, you can use a regular expression in the Replace box to do substitutions in the target segments. The regular expression is used to generate the text that will replace the matched text in the Find criteria.
Example
You could use this feature to change the order of words in a sentence across all occurrences of that sentence.
Find Criteria
Use this regular expression in the Find box:
- field '(\w+)'
It finds matching sentences in the document where XYZ represents the field name:
- "The field 'XYZ' is displayed."
For example, it might find the following sentences:
- "The field Address is displayed."
- "The field Name is displayed."
- "The field Email is displayed."
Replace Criteria
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.