diff options
author | Michael DeHaan <michael@ansible.com> | 2014-04-29 16:53:52 -0400 |
---|---|---|
committer | Michael DeHaan <michael@ansible.com> | 2014-04-29 16:54:14 -0400 |
commit | 9a70dd1c94c819783e68a5b5363f729b0c1b8d8b (patch) | |
tree | e205f7c80931e3f046e05f30e8f7f4563b55dae0 /docsite | |
parent | dc4f198bad6d15c20e4972980f7a230c74c2c25a (diff) | |
download | ansible-9a70dd1c94c819783e68a5b5363f729b0c1b8d8b.tar.gz |
Slight tweak to regex examples.
Diffstat (limited to 'docsite')
-rw-r--r-- | docsite/rst/playbooks_variables.rst | 6 |
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" |