Skip to content

Commit c876a23

Browse files
committed
Merge branch '5.4' into 6.0
* 5.4: [String] Fix the explanation of trimPrefix and trimSuffix
2 parents 6b72682 + c733953 commit c876a23

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
@@ -294,11 +294,16 @@ Methods to Pad and Trim
294294
u(' Lorem Ipsum ')->trimStart(); // 'Lorem Ipsum '
295295
u(' Lorem Ipsum ')->trimEnd(); // ' Lorem Ipsum'
296296

297-
// removes the given content(s) from the start/end of the string
298-
u('file-0001.png')->trimPrefix('file-'); // '0001.png'
299-
u('file-0001.png')->trimPrefix(['file-', 'image-']); // '0001.png'
297+
// removes the given content from the start/end of the string
298+
u('file-image-0001.png')->trimPrefix('file-'); // 'image-0001.png'
299+
u('file-image-0001.png')->trimPrefix('image-'); // 'file-image-0001.png'
300+
u('file-image-0001.png')->trimPrefix('file-image-'); // '0001.png'
301+
u('template.html.twig')->trimSuffix('.html'); // 'template.html.twig'
300302
u('template.html.twig')->trimSuffix('.twig'); // 'template.html'
301-
u('template.html.twig')->trimSuffix(['.twig', '.html']); // 'template'
303+
u('template.html.twig')->trimSuffix('.html.twig'); // 'template'
304+
// when passing an array of prefix/sufix, only the first one found is trimmed
305+
u('file-image-0001.png')->trimPrefix(['file-', 'image-']); // 'image-0001.png'
306+
u('template.html.twig')->trimSuffix(['.twig', '.html']); // 'template.html'
302307

303308
Methods to Search and Replace
304309
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)