ansible.builtin.match test – Does string match regular expression from the start
Note
This test plugin is part of ansible-core
and included in all Ansible installations. In most cases, you can use the short plugin name match
. However, we recommend you use the Fully Qualified Collection Name (FQCN) ansible.builtin.match
for easy linking to the plugin documentation and to avoid conflicting with other collections that may have the same test plugin name.
Synopsis
- Compare string against regular expression using Python’s match function, this means the regex is automatically anchored at the start of the string.
Input
This describes the input of the test, the value before is ansible.builtin.match
or is not ansible.builtin.match
.
Parameter | Comments |
---|---|
Input string / required | String to match. |
Keyword parameters
This describes keyword parameters of the test. These are the values key1=value1
, key2=value2
and so on in the following examples: input is ansible.builtin.match(key1=value1, key2=value2, ...)
and input is not ansible.builtin.match(key1=value1, key2=value2, ...)
Parameter | Comments |
---|---|
ignorecase boolean | Use case insensitive matching. Choices:
|
multiline boolean | Match against multiple lines in string. Choices:
|
pattern string / required | Regex to match against. |
Examples
url: "https://example.com/users/foo/resources/bar" foundmatch: url is match("https://example.com/users/.*/resources") nomatch: url is match("/users/.*/resources")
Return Value
Key | Description |
---|---|
Return value boolean | Returns Returned: success |
Collection links
© 2012–2018 Michael DeHaan
© 2018–2024 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/collections/ansible/builtin/match_test.html