We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents e1e7717 + a579a36 commit 1bcb360Copy full SHA for 1bcb360
components/string.rst
@@ -294,6 +294,16 @@ Methods to Pad and Trim
294
u(' Lorem Ipsum ')->trimStart(); // 'Lorem Ipsum '
295
u(' Lorem Ipsum ')->trimEnd(); // ' Lorem Ipsum'
296
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
307
Methods to Search and Replace
308
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
309
0 commit comments