Skip to content

Commit cc31cf4

Browse files
committed
[String] Document trimPrefix() and trimSufix() methods
1 parent 9a3cdf2 commit cc31cf4

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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy