mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-22 00:00:22 -07:00
regex_escape: support POSIX basic regex (#50327)
This commit is contained in:
parent
874fd70d10
commit
e55e8fe2c4
3 changed files with 31 additions and 3 deletions
|
@ -1075,11 +1075,18 @@ To replace text in a string with regex, use the "regex_replace" filter::
|
|||
|
||||
.. versionadded:: 2.0
|
||||
|
||||
To escape special characters within a regex, use the "regex_escape" filter::
|
||||
To escape special characters within a standard python regex, use the "regex_escape" filter (using the default re_type='python' option)::
|
||||
|
||||
# convert '^f.*o(.*)$' to '\^f\.\*o\(\.\*\)\$'
|
||||
{{ '^f.*o(.*)$' | regex_escape() }}
|
||||
|
||||
.. versionadded:: 2.8
|
||||
|
||||
To escape special characters within a POSIX basic regex, use the "regex_escape" filter with the re_type='posix_basic' option::
|
||||
|
||||
# convert '^f.*o(.*)$' to '\^f\.\*o(\.\*)\$'
|
||||
{{ '^f.*o(.*)$' | regex_escape('posix_basic') }}
|
||||
|
||||
|
||||
Kubernetes Filters
|
||||
``````````````````
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue