Skip to content

Commit 1bcb360

Browse files
committed
Merge branch '5.4' into 6.0
* 5.4: [String] Document trimPrefix() and trimSufix() methods
2 parents e1e7717 + a579a36 commit 1bcb360

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
@@ -294,6 +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'
300+
u('template.html.twig')->trimSuffix('.twig'); // 'template.html'
301+
u('template.html.twig')->trimSuffix(['.twig', '.html']); // 'template'
302+
303+
.. versionadded:: 5.4
304+
305+
The ``trimPrefix()`` and ``trimSuffix()`` methods were introduced in Symfony 5.4.
306+
297307
Methods to Search and Replace
298308
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
299309

0 commit comments

Comments
 (0)