Commit 9a70dd1c by Michael DeHaan

Slight tweak to regex examples.

parent dc4f198b
......@@ -304,12 +304,14 @@ To match strings against a regex, use the "match" or "search" filter::
url: "http://example.com/users/foo/resources/bar"
tasks:
- debug: 'msg="Resource URI: {{ url }}"'
- shell: "msg='matched pattern 1'"
when: url | match("http://example.com/users/.*/resources/.*")
- debug: 'msg="Resource path: {{ url }}"'
- debug: "msg='matched pattern 2'"
when: url | search("/users/.*/resources/.*")
'match' will require a complete match in the string, while 'search' will require a match inside of the string.
To replace text in a string with regex, use the "regex_replace" filter::
# 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