summaryrefslogtreecommitdiff
path: root/docsite
diff options
context:
space:
mode:
authorChris Conway <clconway@google.com>2014-04-14 08:25:41 -0700
committerChris Conway <clconway@google.com>2014-04-14 08:25:41 -0700
commitbeba4c5a1acab36370104baf535164a1e78ca159 (patch)
tree35e3d49b18490c4a577eb81f513e445526bae619 /docsite
parent9210a96825c8b1f5e03ba6b6d1f2924bab74ef7a (diff)
downloadansible-beba4c5a1acab36370104baf535164a1e78ca159.tar.gz
Adds search/match examples to "Playbooks > Variables > Jinja2 Filters" doc section.
Diffstat (limited to 'docsite')
-rw-r--r--docsite/rst/playbooks_variables.rst12
1 files changed, 12 insertions, 0 deletions
diff --git a/docsite/rst/playbooks_variables.rst b/docsite/rst/playbooks_variables.rst
index ce70daf54f..8ae0b92c30 100644
--- a/docsite/rst/playbooks_variables.rst
+++ b/docsite/rst/playbooks_variables.rst
@@ -291,6 +291,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:
+ foo: abcdefg
+
+ tasks:
+ - shell: echo "String '{{ foo }}' matches 'abc'"
+ when: foo | match("abc")
+
+ - shell: echo "String '{{ foo }}' contains 'def'"
+ when: foo | search("def")
+
To replace text in a string with regex, use the "regex_replace" filter::
# convert "ansible" to "able"