From 10bd37436cb23fd7d7166b91d06d2e580460e889 Mon Sep 17 00:00:00 2001 From: Sandra McCann Date: Tue, 3 Aug 2021 10:52:46 -0400 Subject: [PATCH] reword the regex note --- docs/docsite/rst/user_guide/playbooks_filters.rst | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/docs/docsite/rst/user_guide/playbooks_filters.rst b/docs/docsite/rst/user_guide/playbooks_filters.rst index 4d37b1c9e36..53217640b64 100644 --- a/docs/docsite/rst/user_guide/playbooks_filters.rst +++ b/docs/docsite/rst/user_guide/playbooks_filters.rst @@ -1817,16 +1817,20 @@ The ``regex_search`` filter returns an empty string if it cannot find a match: {{ 'ansible' | regex_search('foobar') }} # => '' -Note that due to historic behavior and custom re-implementation of some of the Jinja internals in Ansible there is an exception to the behavior. When used in a Jinja expression (for example in conjunction with operators, other filters, and so on) the return value differs, in those situations the return value is ``none``. See the two examples below: -.. code-block:: yaml+jinja +.. note:: + + + The ``regex_search`` filter returns ``none`` when used in a Jinja expression (for example in conjunction with operators, other filters, and so on). See the two examples below. + + .. code-block:: Jinja {{ 'ansible' | regex_search('foobar') == '' }} # => False - {{ 'ansible' | regex_search('foobar') == none }} + {{ 'ansible' | regex_search('foobar') is none }} # => True -When ``jinja2_native`` setting is enabled, the ``regex_search`` filter always returns ``none`` if it cannot find a match. + This is due to historic behavior and the custom re-implementation of some of the Jinja internals in Ansible. Enable the ``jinja2_native`` setting if you want the ``regex_search`` filter to always return ``none`` if it cannot find a match. To extract all occurrences of regex matches in a string, use the ``regex_findall`` filter: @@ -2029,7 +2033,7 @@ To split a string into a list: .. code-block:: yaml+jinja {{ csv_string | split(",") }} - + .. versionadded:: 2.11 To work with Base64 encoded strings: