ansible.builtin.regex_escape filter – escape regex chars
Note
This filter plugin is part of ansible-core
and included in all Ansible
installations. In most cases, you can use the short
plugin name
regex_escape
.
However, we recommend you use the Fully Qualified Collection Name (FQCN) ansible.builtin.regex_escape
for easy linking to the
plugin documentation and to avoid conflicting with other collections that may have
the same filter plugin name.
New in Ansible 2.8
Synopsis
Escape special characters in a string for use in a regular expression.
Input
This describes the input of the filter, the value before | ansible.builtin.regex_escape
.
Parameter |
Comments |
---|---|
String to escape. |
Positional parameters
This describes positional parameters of the filter. These are the values positional1
, positional2
and so on in the following
example: input | ansible.builtin.regex_escape(positional1, positional2, ...)
Parameter |
Comments |
---|---|
Which type of escaping to use. Choices:
|
Notes
Note
posix_extended is not implemented yet
Examples
# safe_for_regex => '\^f\.\*o\(\.\*\)\$'
safe_for_regex: "{{ '^f.*o(.*)$' | regex_escape() }}"
Return Value
Key |
Description |
---|---|
Escaped string. Returned: success |
Hint
Configuration entries for each entry type have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up.