Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitcc31cf4

Browse files
committed
[String] Document trimPrefix() and trimSufix() methods
1 parent9a3cdf2 commitcc31cf4

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

‎components/string.rst‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +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'
312+
u('template.html.twig')->trimSuffix('.twig'); // 'template.html'
313+
u('template.html.twig')->trimSuffix(['.twig', '.html']); // 'template'
314+
315+
..versionadded::5.4
316+
317+
The ``trimPrefix()`` and ``trimSuffix()`` methods were introduced in Symfony 5.4.
318+
309319
Methods to Search and Replace
310320
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
311321

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp