From 5e26ce7320650a26fc2579c651691e74f3b2ca6d Mon Sep 17 00:00:00 2001 From: Axel Venet Date: Thu, 7 Apr 2022 15:41:53 +0200 Subject: [PATCH 1/2] [Documentation] Add note about simple string matching Mention the use of ``in`` operator when looking for a simple string instead of ``matches``. #Symfony_Live --- doc/templates.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/templates.rst b/doc/templates.rst index 8e26e330a5c..2e5a2dd3c8e 100644 --- a/doc/templates.rst +++ b/doc/templates.rst @@ -664,6 +664,8 @@ string: {% if phone matches '/^[\\d\\.]+$/' %} {% endif %} + For simple string comparisons, the containment operator can be used. + Containment Operator ~~~~~~~~~~~~~~~~~~~~ From ab36653962ab265354c706eb04f7ce2899bbab66 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 9 Apr 2022 10:41:02 +0200 Subject: [PATCH 2/2] Tweak previous commit --- doc/templates.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/templates.rst b/doc/templates.rst index 2e5a2dd3c8e..121118f2e91 100644 --- a/doc/templates.rst +++ b/doc/templates.rst @@ -643,8 +643,7 @@ Comparisons The following comparison operators are supported in any expression: ``==``, ``!=``, ``<``, ``>``, ``>=``, and ``<=``. -You can also check if a string ``starts with`` or ``ends with`` another -string: +Check if a string ``starts with`` or ``ends with`` another string: .. code-block:: twig @@ -654,6 +653,9 @@ string: {% if 'Fabien' ends with 'n' %} {% endif %} +Check that a string contains another string via the containment operator (see +next section). + .. note:: For complex string comparisons, the ``matches`` operator allows you to use @@ -664,8 +666,6 @@ string: {% if phone matches '/^[\\d\\.]+$/' %} {% endif %} - For simple string comparisons, the containment operator can be used. - Containment Operator ~~~~~~~~~~~~~~~~~~~~