Ansible Filter regex replace: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 6: Line 6:


=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', '...', '...') | list
</syntaxhighlight>
<syntaxhighlight lang='text'>
"{{ java_modules_result.files | json_query('[*].path') | map('regex_replace', '(.*/Contents/Home)/jmods/(.*)\\.jmod', 'jrt://\\1!/\\2') | list }}"
</syntaxhighlight>

Revision as of 09:17, 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', '...', '...') | list
"{{ java_modules_result.files | json_query('[*].path') | map('regex_replace', '(.*/Contents/Home)/jmods/(.*)\\.jmod', 'jrt://\\1!/\\2') | list }}"