From a7f90df0e9de54dfb3d4411149f050906f062bf1 Mon Sep 17 00:00:00 2001 From: James Cassell Date: Wed, 13 Nov 2019 12:14:10 -0500 Subject: [PATCH] Document match/search tests (#64775) * clarify `search` vs `match` tests * string test docs: fix rst formatting --- docs/docsite/rst/user_guide/playbooks_tests.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/docsite/rst/user_guide/playbooks_tests.rst b/docs/docsite/rst/user_guide/playbooks_tests.rst index 986325823ce..c54ee299626 100644 --- a/docs/docsite/rst/user_guide/playbooks_tests.rst +++ b/docs/docsite/rst/user_guide/playbooks_tests.rst @@ -37,7 +37,7 @@ Such as:: Testing strings ``````````````` -To match strings against a substring or a regular expression, use the "match", "search" or "regex" filters:: +To match strings against a substring or a regular expression, use the ``match``, ``search`` or ``regex`` filters:: vars: url: "http://example.com/users/foo/resources/bar" @@ -45,7 +45,7 @@ To match strings against a substring or a regular expression, use the "match", " tasks: - debug: msg: "matched pattern 1" - when: url is match("http://example.com/users/.*/resources/.*") + when: url is match("http://example.com/users/.*/resources/") - debug: msg: "matched pattern 2" @@ -59,7 +59,7 @@ To match strings against a substring or a regular expression, use the "match", " msg: "matched pattern 4" when: url is regex("example.com/\w+/foo") -'match' requires zero or more characters at the beginning of the string, while 'search' only requires matching a subset of the string. By default, 'regex' works like `search`, but `regex` can be configured to perform other tests as well. +``match`` succeeds if it finds the pattern at the beginning of the string, while ``search`` succeeds if it finds the pattern anywhere within string. By default, ``regex`` works like ``search``, but ``regex`` can be configured to perform other tests as well. .. _testing_truthiness: