Include Page |
---|
SUPPORTS:How to use findReplace | SUPPORTS:How to use findReplace Table of Contents |
---|
maxLevel | 4 |
---|
minLevel | 3 |
---|
type | flat |
---|
separator | pipe |
---|
|
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 logic. Some scenarios require the more complex. Note that is string manipulation of some content.
Scenarios
Table plus |
---|
|
Scenario | Example | Discussion |
---|
Simple |
No Format |
---|
--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 |
No Format |
---|
--findReplace AAA:BBB,XXX:YYY |
| More generally, the findReplace parameter is a comma separated lists of find replace pairs. | Regex |
No Format |
---|
--findReplaceRegex XXX-(\d+):YYY-$1 |
| Regular expressions 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 and the reference links. | Blanks |
No Format |
---|
--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. | Separators and quotes |
No Format |
---|
--findReplace 'AAA:BBB':YYY |
No Format |
---|
--findReplace "'AAA,BBB:YYY,ZZZ'" |
| Just like other separated list parameters, if a separator is part of the text, then the element must be single quoted. See Tips. Similarly embedded double quotes must be handled. See Tips. 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 for examples. |
|
Example Usage
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 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 action can modify existing page content using findReplace logic. |
|