Search and Replace Filter
The Search and Replace filter searches for a given string or regular expression in the input text and replaces it with a string or regular expression submatch. When doing a Regular Expression search and replace using $1-$9 in the replacement text will match the appropriate submatched potion of the input text.
| setting | description |
|---|---|
| Search | The string or regular expression to search for in the input text. |
| Replace | This string will be substituted in the input text for any match. |
| Ignore Case | When set do a case insensitive match on the input text. |
| Regular Expression | Enables POSIX style regular expression matching. |
| Individual Lines | Each line is treated as a separate string and run through the Reg Ex search and replace one at a time. |
| Contains | This causes matches to only when any portion of a string matches the search term. |
| Starts With | This causes matches to only occur when a string starts with the search term. |
| Whole Words | This causes matches to only occur when a string fully matches the search term. |
| Ends With | This causes matches to only occur when a string ends with the search term. |
| input | output | options |
|---|---|---|
| This is a TEST string. | This is a Test string. | Search = est
Replace = est Ignore Case Contains |
| This is a TEST string. | This is a TEST string. | Search = est
Replace = est Contains |
| This is a TEST string. | THIs is a TEST string. | Search = Thi
Replace = THI Starts With |
| This is a TEST string. | THIS is a TEST string. | Search = his
Replace = HIS Ends With |
| This is a TEST string. | THIS is a TEST string. | Search = This
Replace = THIS Whole Words |
| This is a TEST string. | Replaced is a Replaced string. | Search = T.{3}
Replace = Replaced Regular Expression Replace T and any 3 characters that follow it |
| This is a TEST string. | ********************** | Search = .
Replace = * Regular Expression Replace all characters with * |
| This is a TEST string. | "This" is a "TEST" string. | Search = ([[:alpha:]]{4})
Replace = "$1" Regular Expression Quote all 4 character strings |
| AB
AB |
BB
AB |
Search = ^A
Replace = B Regular Expression Match the start of the input followed by A |
| AB
AB |
BB
BB |
Search = ^A
Replace = B Regular Expression Individual Lines Match the start of each line followed by A |
Tip:
Enclosing any portion of a regular expression in () will create a submatch that can be used in the replacement by using $X to choose the particular part of the submatch you want to include (where X is the submatch you want to use, starting with 1)