Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 38bfd69

Browse filesBrowse files
committed
[String] Fix the explanation of trimPrefix and trimSuffix
1 parent 6e83621 commit 38bfd69
Copy full SHA for 38bfd69

File tree

1 file changed

+9
-4
lines changed
Filter options

1 file changed

+9
-4
lines changed

‎components/string.rst

Copy file name to clipboardExpand all lines: components/string.rst
+9-4Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.