Skip to content

Commit c733953

Browse files
committed
minor #15968 [String] Fix the explanation of trimPrefix and trimSuffix (javiereguiluz)
This PR was squashed before being merged into the 5.4 branch. Discussion ---------- [String] Fix the explanation of trimPrefix and trimSuffix Fixes #15951. Commits ------- 38bfd69 [String] Fix the explanation of trimPrefix and trimSuffix
2 parents 6e83621 + 38bfd69 commit c733953

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

components/string.rst

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -306,11 +306,16 @@ Methods to Pad and Trim
306306
u(' Lorem Ipsum ')->trimStart(); // 'Lorem Ipsum '
307307
u(' Lorem Ipsum ')->trimEnd(); // ' Lorem Ipsum'
308308

309-
// 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'
309+
// removes the given content from the start/end of the string
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-', 'image-']); // 'image-0001.png'
318+
u('template.html.twig')->trimSuffix(['.twig', '.html']); // 'template.html'
314319

315320
.. versionadded:: 5.4
316321

0 commit comments

Comments
 (0)