# Okapi Framework - Steps ## Search and Replace Step
- Overview - Parameters |
Steps | Developer's Guide | Okapi Framework

If you are using an Okapi Tool after the M9 release, you should be using the wiki online help:
http://www.opentag.com/okapi/wiki/index.php?title=Search_and_Replace_Step

## Overview

This step performs search and replace actions on either the text units or the full content of input documents.

Takes: Raw document or Filter events
Sends: Raw document or Filter events

The step provides a way to define a list of search entries and corresponding replacement. You can use regular expressions if needed.

The step can take ither as input either a raw document, or filter events.

- If the step recieves filter events, the search and replace is done on the content of the text units, and the step sends updated filter events to the next step.
- If the step recieves a raw document, the search and replace is done on the whole file, and the step sends an updated raw document to the next step. Note that in this case, the raw document must be in some text-based file format for the search and replace to work: The document is seen exactly like it would be in a text editor (no conversion of escaped characters is done for example).

## Parameters

The items list contains three columns:

- The Use column where a check box indicates if the given pattern should be used (checked) or not (un-checked).
- The Search for column where the text or regular expression to search for is displayed.
- The Replace by column where the replacement text or regular expression is displayed.

To edit an item : Double-click the item, or click the Edit button. To check and un-check an item: Click the checkbox, or press `Space` when the item is selected.

Add -- Click this button to add a new item in the list.

Edit -- Click this button to edit the item currently selected.

Remove -- Click this button to remove the item currently selected from the list.

Move Up -- Click this button to move the item currently selected upward.

Move Down -- Click this button to move the item currently selected downward.

Import -- Click this button to import an existing file that contains saved options for this step.

Export -- Click this button to export to a file the current options for this step.

Use regular expressions -- Set this option to enable the Regular Expressions mode. Note that the placeholders to use in the replacement string for the search group are `$1`, `$2`, etc. (`$1` corresponds to the part matching the first group of the search expression, etc.) See the documentation on `Matcher.replaceAll()` for more details. In addition, in the replacement field you can specify "`\n`", "`\r`", and "`\t`" for for line-feed, carriage-return, and tab; as well as "`\N`" to replace by the line-break type of the current platform, for example "`\r\n`" for Windows.

#### Regular expression options

When this option is checked several regular expression options are accessible. They apply to all expressions, not just the selected one:

Ignore case -- Set this option to ignore the cases in the matches. for example "bear" matches "Bearcat", "BEARCAT", and "bearcat".

Multiline -- Set this option to changes the meaning of `^` and `$` so that they match at the beginning and end of any line, not just the beginning and end of the whole string.

Dot also matches line-feed -- Set this option to changes the meaning of the period character '`.`' so that it matches every character instead of every character except `\n`.