Document match/search tests (#64775)
* clarify `search` vs `match` tests * string test docs: fix rst formatting
This commit is contained in:
parent
93d1a57d9a
commit
a7f90df0e9
1 changed files with 3 additions and 3 deletions
|
@ -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:
|
||||
|
||||
|
|
Loading…
Reference in a new issue