Edit template - Find and Replace script

Complex text documents may need to be changed a bit before they can be imported in a memoQ project. This change or conversion is called pre-processing, and it is run before the document is imported.

When a document is pre-processed before import, it needs to be changed back after it is exported. So, if you run pre-processing before importing a document, you need to run post-processing after exporting it.

Most of the time, all you need to do is run a couple of find-and-replace actions on the document. Sometimes you need to use regular expressions for that. You can experiment with these and fine-tune the changes in a developers' text editor such as Notepad++ or UltraEdit.

To do all this, use the Find and Replace script, which is included with memoQ 8.1 and later versions. The Find and Replace script allows you to run a series of find-and-replace actions on documents. You don't need to do any programming. You need to list your find-and-replace actions in a configuration file, using regular expressions. That cuts down on the need for learning - you don't need to learn C# or PowerShell or Python, "only" regular expressions.

Text (plain-text) documents only: The Find and Replace script works with human-readable documents: plain-text documents, tabular text documents (such as CSV), tagged documents (such as XML or HTML), or source-code documents (JSON, .properties, etc.)

This topic describes the following:

  • How to set up the Find and Replace script on memoQ or on memoQ TMS
  • How to write up the find-and-replace operations
  • How to use the Find and Replace script in a project template - for three use cases: pre-processing (before importing), post-processing (after exporting), and during a project (after importing, for example)

Prepare memoQ: Set up the Find and Replace script on your computer

On your computer, the Find and Replace script is installed in the C:\Program Files\memoQ\FindReplace Tool folder.

The folder path is different for older versions: See the documentation for your own memoQ version.

The folder contains the MemoQ.Tools.FindAndReplace.exe program, as well as an .xml file that contains the find-and-replace rules:


On your own computer, the Find and Replace script is ready for use if memoQ 9.12 or later is installed. Take note of the folder path because you will need to use it later.

You may need administrator access: To make changes to this folder (for example, to edit the find-and-replace rules), you may need to enter the user name and the password of an administrator user. If you do not have sufficient access, the User Account Control service in Windows will warn you.

Prepare memoQ TMS: Set up the Find and Replace script on the server computer

Administrator access required: To do this, you need to access the memoQ TMS computer through Remote Desktop, and you need to be an administrator. If you do not have administrator's privileges over the memoQ TMS computer, contact the systems operator of your organization, and point them to this topic.

Set up document conversions: Write up your find-and-replace actions in the configuration file(s)

The Find and Replace tool needs a configuration file to know what to find and how to replace the text it finds.

The configuration file must be in the same folder with the tool itself. So, to set up the actual find-and-replace actions, you need to copy a configuration file to the server computer, or you need to edit the configuration file right there.

The configuration file is not hard-coded. You can pick a configuration file when you call the Find and Replace tool. However, no matter what configuration file you pick, it must be in the folder on the server computer.

You can use a separate configuration file for each document format you need to work with. Or, you can use one single configuration file, and write a separate section for each format and each conversion.

When you set up the automated action in the project template, you need to call on the Find and Replace tool - and then you must choose a configuration file and a section inside the configuration file.

A Find and Replace configuration file is an XML file, which lists find-and-replace actions for one document format. It has several sections, or use cases (usecase elements). Each section or use case is about one of the following actions:

  1. conversions before importing the document (in the example: PreImport),
  2. conversions after exporting the document (in the example: PostExport), or
  3. conversions of documents while they travel through memoQ: after importing, or pre-translating, or completing the document (in the example: PostImport).

You can name these use cases anything you like. For example, you can have an .xml file that has import-export conversions for JSON, as well as import-export conversions for .po files. In this case, the sections for each use case could be called JSON-PreImport, JSON-PostExport, PO-PreImport, PO-PostExport.

If you convert on import, you must convert back on export: If you run PreImport conversions, you will need to run the opposite conversions after export (PostExport).

How can you run find-and-replace on documents that are already inside a project? When you set up a custom action after document import, memoQ TMS will export the document in a plain (uncompressed) memoQ XLIFF file, run it through the script you specify, and import the modified XLIFF file back into the project - all in the background.

You don't have to write up the configuration file from scratch. The FindAndReplace or FindReplace Tool folder contains a sample configuration file. To set up your own conversions, simply make a copy of the example_config.xml file. Replace the conversions in the file with yours.


The Find and Replace tool supports two types of find-replace actions: you can replace plain text - or you can replace text using regular expressions and placeholders.

For each use case, you can write up several find-and-replace rules. Each rule is written in a searchItem element. The type of the searchItem element ("text" or "regex") defines whether you replace plain text or use regular expressions.

In each searchItem element, there is a searchExpression and a replaceExpression element. The searchExpression element must contain exactly one plain-text search term or regular expression. The replaceExpression element must contain exactly one plain-text passage or a replacement rule using placeholders from the regular expression in the searchExpression.

Set up the project template to use the Find and Replace tool

When you finish

To test the Find and Replace script: Create an online project from the template you have just set up, and import a document that should be processed. If the document imports successfully, check out the project and open the document for editing to see if the transformations were correct.

Or, if you are using a local project template: Create a local project from the template you have just set up, and import a document that should be processed. If the document imports successfully, open the document for editing to see if the transformations were correct.

To change the find-and-replace actions: Edit the .xml file you use with the project template. (If you are working with an online template, log on to the memoQ TMS computer through Remote Desktop.) Add or change find-and-replace actions as you see fit. You do not need to change the project template. What's more, you can open an existing project that uses this template, and import new files. Even then, memoQ or memoQ TMS will use the updated find-and-replace actions.

To learn more about find-and-replace actions: Read the Set up conversions section above.