diff options
author | Michael DeHaan <michael.dehaan@gmail.com> | 2014-04-29 16:50:55 -0400 |
---|---|---|
committer | Michael DeHaan <michael.dehaan@gmail.com> | 2014-04-29 16:50:55 -0400 |
commit | cf54098dab438e0c5fc858a37402c990ed550855 (patch) | |
tree | bd4d60d422a26bdc00e166de6102014c20afe413 /docsite | |
parent | 56d03fc7660d150dcce3da73a33ff1718e34d58d (diff) | |
parent | 0ec5d78e208cebbe236a613d7394663c664e3839 (diff) | |
download | ansible-cf54098dab438e0c5fc858a37402c990ed550855.tar.gz |
Merge pull request #6984 from clconway/variable-re-doc
Adds search/match examples to "Playbooks > Variables > Jinja2 Filters" d...
Diffstat (limited to 'docsite')
-rw-r--r-- | docsite/rst/playbooks_variables.rst | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/docsite/rst/playbooks_variables.rst b/docsite/rst/playbooks_variables.rst index b8cfbff380..f09bce8e98 100644 --- a/docsite/rst/playbooks_variables.rst +++ b/docsite/rst/playbooks_variables.rst @@ -298,6 +298,18 @@ doesn't know it is a boolean value:: - debug: msg=test when: some_string_value | bool +To match strings against a regex, use the "match" or "search" filter:: + + vars: + url: "http://example.com/users/foo/resources/bar" + + tasks: + - debug: 'msg="Resource URI: {{ url }}"' + when: url | match("http://example.com/users/.*/resources/.*") + + - debug: 'msg="Resource path: {{ url }}"' + when: url | search("/users/.*/resources/.*") + To replace text in a string with regex, use the "regex_replace" filter:: # convert "ansible" to "able" |