Ansible Filter regex replace: Difference between revisions
Jump to navigation
Jump to search
(2 intermediate revisions by the same user not shown) | |||
Line 4: | Line 4: | ||
* [[Ansible Filters#regex_replace|Ansible Filters]] | * [[Ansible Filters#regex_replace|Ansible Filters]] | ||
=Overview= | =Overview= | ||
=Apply the Regular Expression to Each Element of a List= | =Apply the Regular Expression to Each Element of a List= | ||
The pipeline produces a list that is then processed with <code>regex_replace</code>. | |||
<syntaxhighlight lang='text'> | |||
... | map('regex_replace', '<matching-regex>', '<replacement-expression>') | list | |||
</syntaxhighlight> | |||
<syntaxhighlight lang='text'> | |||
"{{ java_modules_result.files | json_query('[*].path') | map('regex_replace', '(.*/Contents/Home)/jmods/(.*)\\.jmod', 'jrt://\\1!/\\2') | list }}" | |||
</syntaxhighlight> |
Latest revision as of 09:18, 5 July 2021
External
Internal
Overview
Apply the Regular Expression to Each Element of a List
The pipeline produces a list that is then processed with regex_replace
.
... | map('regex_replace', '<matching-regex>', '<replacement-expression>') | list
"{{ java_modules_result.files | json_query('[*].path') | map('regex_replace', '(.*/Contents/Home)/jmods/(.*)\\.jmod', 'jrt://\\1!/\\2') | list }}"