---
title: "How to use findReplace"
canonical: "https://support.appfire.com/space/SUPPORT/89147470/How%20to%20use%20findReplace"
format: markdown
---
> Macro (toc)

# Summary

Many actions support the **findReplace** and **findReplaceRegex** parameters. These provide powerful re-use capabilities for automation by enabling templates (with the generic meaning of the word) to be used. The replacements occur at time of use. Use can be a very simple replacement like **–findReplace XXX:YYY** to very complex list of replacements using [regex](https://appfire.atlassian.net/wiki/spaces/info/pages/86082100) logic. Some scenarios require the more complex. Note that is string manipulation of some content.

# Scenarios

> Macro (table-plus)
> 
> | **Scenario** | **Example** | **Discussion** |
> | --- | --- | --- |
> | Simple | ```
> --findReplace XXX:YYY
> ``` | Find XXX in the content and replace it with YYY. The find replace parameter is made of a pair of strings separated by a **:** (colon). The first element is the string to find and the second element is the replacement string. |
> | Multiple | ```
> --findReplace AAA:BBB --findReplace XXX:YYY
> ``` | Multiple findReplace parameters can be used. |
> | Regex | ```
> --findReplaceRegex XXX-(\d+):YYY-$1
> ``` | [Regular expressions](https://appfire.atlassian.net/wiki/spaces/info/pages/86082100) provide even more powerful capabilities for finding and replacing text. In this case the first element of the pair must be a valid regex expression and the second element of the pair can use replacement variables ($1, $2, ...) to represent capture groups. See [How to use regular expressions](https://appfire.atlassian.net/wiki/spaces/info/pages/86082100) and the reference links. |
> | Blanks | ```
> --findReplace "AAA BBB:YYY ZZZ"
> ``` | Just like any other CLI parameter. If it contains blanks, it must be double quoted and embedded double quotes must be handled. See [Tips](https://appfire.atlassian.net/wiki/display/ACLI/Tips). |
> | Separators and quotes | ```
> --findReplace 'AAA:BBB':YYY
> ``` | Just like other separated list parameters, if a separator is part of the text, then the element must be single quoted. See [Tips](https://appfire.atlassian.net/wiki/display/ACLI/Tips).<br>Similarly embedded double quotes must be handled. See [Tips](https://appfire.atlassian.net/wiki/display/ACLI/Tips).<br>If the element values contain lots of separators and/or quotes, it gets really complicated and difficult to read. The **special** parameter provides relief by allowing you to use different separator and quoting characters to be recognized instead so your element text can be used directly with modification. Confluence storage format is one of the worse case examples of this 🙁 so use of the **special** parameter is highly recommended for these scenarios. See the **special** parameter section of [Tips](https://appfire.atlassian.net/wiki/display/ACLI/Tips) for examples. |

# Example Usage

> Macro (table-plus)
> 
> | **Use** | **Discussion** |
> | --- | --- |
> | **run** | The run action can run a list of actions provided in a file. This can be parameterized by using **findReplace**. |
> | **copyPages** | The Confluence CLI [copyPage](https://appfire.atlassian.net/wiki/display/CSOAP/Documentation#Documentation-copyPage) action can be used to copy a page hierarchy (used as a template) to create new pages using **findReplace** to automatically modify the contents on the copy. |
> | **modifyPage** | The Confluence CLI [modifyPage](https://appfire.atlassian.net/wiki/display/CSOAP/Documentation#Documentation-modifyPage) action can modify existing page content using **findReplace** logic. |