From 38bfd690c85458a61f6b37410f273d89c1b65149 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 20 Oct 2021 15:46:58 +0200 Subject: [PATCH] [String] Fix the explanation of trimPrefix and trimSuffix --- components/string.rst | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/components/string.rst b/components/string.rst index e4901d9591c..d9d533880f9 100644 --- a/components/string.rst +++ b/components/string.rst @@ -306,11 +306,16 @@ Methods to Pad and Trim u(' Lorem Ipsum ')->trimStart(); // 'Lorem Ipsum ' u(' Lorem Ipsum ')->trimEnd(); // ' Lorem Ipsum' - // removes the given content(s) from the start/end of the string - u('file-0001.png')->trimPrefix('file-'); // '0001.png' - u('file-0001.png')->trimPrefix(['file-', 'image-']); // '0001.png' + // removes the given content from the start/end of the string + u('file-image-0001.png')->trimPrefix('file-'); // 'image-0001.png' + u('file-image-0001.png')->trimPrefix('image-'); // 'file-image-0001.png' + u('file-image-0001.png')->trimPrefix('file-image-'); // '0001.png' + u('template.html.twig')->trimSuffix('.html'); // 'template.html.twig' u('template.html.twig')->trimSuffix('.twig'); // 'template.html' - u('template.html.twig')->trimSuffix(['.twig', '.html']); // 'template' + u('template.html.twig')->trimSuffix('.html.twig'); // 'template' + // when passing an array of prefix/sufix, only the first one found is trimmed + u('file-image-0001.png')->trimPrefix(['file-', 'image-']); // 'image-0001.png' + u('template.html.twig')->trimSuffix(['.twig', '.html']); // 'template.html' .. versionadded:: 5.4