diff --git a/components/string.rst b/components/string.rst index 48f17f0b3e9..e4901d9591c 100644 --- a/components/string.rst +++ b/components/string.rst @@ -306,6 +306,16 @@ Methods to Pad and Trim u(' Lorem Ipsum ')->trimStart(); // 'Lorem Ipsum ' u(' Lorem Ipsum ')->trimEnd(); // ' Lorem Ipsum' + // removes the given content(s) from the start/end of the string + u('file-0001.png')->trimPrefix('file-'); // '0001.png' + u('file-0001.png')->trimPrefix(['file-', 'image-']); // '0001.png' + u('template.html.twig')->trimSuffix('.twig'); // 'template.html' + u('template.html.twig')->trimSuffix(['.twig', '.html']); // 'template' + +.. versionadded:: 5.4 + + The ``trimPrefix()`` and ``trimSuffix()`` methods were introduced in Symfony 5.4. + Methods to Search and Replace ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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: