summaryrefslogtreecommitdiff
path: root/docsite
diff options
context:
space:
mode:
authorMichael DeHaan <michael@ansible.com>2014-04-29 16:53:52 -0400
committerMichael DeHaan <michael@ansible.com>2014-04-29 16:54:14 -0400
commit9a70dd1c94c819783e68a5b5363f729b0c1b8d8b (patch)
treee205f7c80931e3f046e05f30e8f7f4563b55dae0 /docsite
parentdc4f198bad6d15c20e4972980f7a230c74c2c25a (diff)
downloadansible-9a70dd1c94c819783e68a5b5363f729b0c1b8d8b.tar.gz
Slight tweak to regex examples.
Diffstat (limited to 'docsite')
-rw-r--r--docsite/rst/playbooks_variables.rst6
1 files changed, 4 insertions, 2 deletions
diff --git a/docsite/rst/playbooks_variables.rst b/docsite/rst/playbooks_variables.rst
index f09bce8e98..34bfb85126 100644
--- a/docsite/rst/playbooks_variables.rst
+++ b/docsite/rst/playbooks_variables.rst
@@ -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"