Ansible Filter regex replace: Difference between revisions
Jump to navigation
Jump to search
Line 8: | Line 8: | ||
The pipeline produces a list that is then processed with <code>regex_replace</code>. | The pipeline produces a list that is then processed with <code>regex_replace</code>. | ||
<syntaxhighlight lang='text'> | <syntaxhighlight lang='text'> | ||
... | map('regex_replace', ' | ... | map('regex_replace', '<matching-regex>', '<replacement-expression>') | list | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<syntaxhighlight lang='text'> | <syntaxhighlight lang='text'> | ||
"{{ java_modules_result.files | json_query('[*].path') | map('regex_replace', '(.*/Contents/Home)/jmods/(.*)\\.jmod', 'jrt://\\1!/\\2') | list }}" | "{{ java_modules_result.files | json_query('[*].path') | map('regex_replace', '(.*/Contents/Home)/jmods/(.*)\\.jmod', 'jrt://\\1!/\\2') | list }}" | ||
</syntaxhighlight> | </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 }}"