Ansible Filter regex replace

From NovaOrdis Knowledge Base
Jump to navigation Jump to search

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 }}"