Commit beba4c5a by Chris Conway

Adds search/match examples to "Playbooks > Variables > Jinja2 Filters" doc section.

parent 9210a968
...@@ -291,6 +291,18 @@ doesn't know it is a boolean value:: ...@@ -291,6 +291,18 @@ doesn't know it is a boolean value::
- debug: msg=test - debug: msg=test
when: some_string_value | bool when: some_string_value | bool
To match strings against a regex, use the "match" or "search" filter::
vars:
foo: abcdefg
tasks:
- shell: echo "String '{{ foo }}' matches 'abc'"
when: foo | match("abc")
- shell: echo "String '{{ foo }}' contains 'def'"
when: foo | search("def")
To replace text in a string with regex, use the "regex_replace" filter:: To replace text in a string with regex, use the "regex_replace" filter::
# convert "ansible" to "able" # convert "ansible" to "able"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment