|
|
@ -401,6 +401,11 @@ To replace text in a string with regex, use the "regex_replace" filter::
|
|
|
|
.. note:: If "regex_replace" filter is used with variables inside YAML arguments (as opposed to simpler 'key=value' arguments),
|
|
|
|
.. note:: If "regex_replace" filter is used with variables inside YAML arguments (as opposed to simpler 'key=value' arguments),
|
|
|
|
then you need to escape backreferences (e.g. ``\\1``) with 4 backslashes (``\\\\``) instead of 2 (``\\``).
|
|
|
|
then you need to escape backreferences (e.g. ``\\1``) with 4 backslashes (``\\\\``) instead of 2 (``\\``).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
To escape special characters within a regex, use the "regex_escape" filter::
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# convert '^f.*o(.*)$' to '\^f\.\*o\(\.\*\)\$'
|
|
|
|
|
|
|
|
{{ '^f.*o(.*)$' | regex_escape() }}
|
|
|
|
|
|
|
|
|
|
|
|
A few useful filters are typically added with each new Ansible release. The development documentation shows
|
|
|
|
A few useful filters are typically added with each new Ansible release. The development documentation shows
|
|
|
|
how to extend Ansible filters by writing your own as plugins, though in general, we encourage new ones
|
|
|
|
how to extend Ansible filters by writing your own as plugins, though in general, we encourage new ones
|
|
|
|
to be added to core so everyone can make use of them.
|
|
|
|
to be added to core so everyone can make use of them.
|
|
|
|