From f140ba2e1ce1c980c7347737dd834f2f6e01fad7 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 18 Mar 2020 12:12:28 +0100 Subject: [PATCH] [String] Added the containsAny() method --- components/string.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/components/string.rst b/components/string.rst index 1f2dbad3d3a..68b5f190fdb 100644 --- a/components/string.rst +++ b/components/string.rst @@ -300,6 +300,11 @@ Methods to Search and Replace u('avatar-73647.png')->match('/avatar-(\d+)\.png/'); // result = ['avatar-73647.png', '73647'] + // checks if the string contains any of the other given strings + u('aeiou')->containsAny('a'); // true + u('aeiou')->containsAny(['ab', 'efg']); // false + u('aeiou')->containsAny(['eio', 'foo', 'z']); // true + // finds the position of the first occurrence of the given string // (the second argument is the position where the search starts and negative // values have the same meaning as in PHP functions) @@ -327,6 +332,10 @@ Methods to Search and Replace return '['.$match[0].']'; }); // result = '[1][2][3]' +.. versionadded:: 5.1 + + The ``containsAny()`` method was introduced in Symfony 5.1. + Methods to Join, Split, Truncate and Reverse ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~