Commit 0ec5d78e by Chris Conway

Modifies match/search filter examples to use non-trivial regexes.

parent beba4c5a
...@@ -294,14 +294,14 @@ doesn't know it is a boolean value:: ...@@ -294,14 +294,14 @@ doesn't know it is a boolean value::
To match strings against a regex, use the "match" or "search" filter:: To match strings against a regex, use the "match" or "search" filter::
vars: vars:
foo: abcdefg url: "http://example.com/users/foo/resources/bar"
tasks: tasks:
- shell: echo "String '{{ foo }}' matches 'abc'" - debug: 'msg="Resource URI: {{ url }}"'
when: foo | match("abc") when: url | match("http://example.com/users/.*/resources/.*")
- shell: echo "String '{{ foo }}' contains 'def'" - debug: 'msg="Resource path: {{ url }}"'
when: foo | search("def") when: url | search("/users/.*/resources/.*")
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::
......
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