Skip to content

Commit bf39904

Browse files
committed
[String] Fix the explanation of trimPrefix and trimSufix
1 parent 6e83621 commit bf39904

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

components/string.rst

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,10 +307,15 @@ Methods to Pad and Trim
307307
u(' Lorem Ipsum ')->trimEnd(); // ' Lorem Ipsum'
308308

309309
// removes the given content(s) from the start/end of the string
310-
u('file-0001.png')->trimPrefix('file-'); // '0001.png'
311-
u('file-0001.png')->trimPrefix(['file-', 'image-']); // '0001.png'
310+
u('file-image-0001.png')->trimPrefix('file-'); // 'image-0001.png'
311+
u('file-image-0001.png')->trimPrefix('image-'); // 'file-image-0001.png'
312+
u('file-image-0001.png')->trimPrefix('file-image-'); // '0001.png'
313+
u('template.html.twig')->trimSuffix('.html'); // 'template.html.twig'
312314
u('template.html.twig')->trimSuffix('.twig'); // 'template.html'
313-
u('template.html.twig')->trimSuffix(['.twig', '.html']); // 'template'
315+
u('template.html.twig')->trimSuffix('.html.twig'); // 'template'
316+
// when passing an array of prefix/sufix, only the first one found is trimmed
317+
u('file-image-0001.png')->trimPrefix(['file', 'file-']); // '-image-0001.png'
318+
u('template.html.twig')->trimSuffix(['.twig', '.html']); // 'template.html'
314319

315320
.. versionadded:: 5.4
316321

0 commit comments

Comments
 (0)