Slight tweak to regex examples.

pull/7154/merge
Michael DeHaan 11 years ago
parent dc4f198bad
commit 9a70dd1c94

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

Loading…
Cancel
Save