Trim character from string

I’m trying to trim a vimeo link.
https://vimeo.com/1234567890
Where you remove
https://vimeo.com/ (removes 18 characters).

So I saw online you can use Str::trim() | Kirby CMS but I have no clue on how to use it.
Also,
I saw the ->short() method but it removes the end of the string, I would like to remove the begining.

But I don’t really know how to use it…
Thanks!

Actually you don’t want to trim the string (in your case the link), which means removing certain characters (usually blanks) from the left or right side of the string - you want to get rid of a part of a string. For that, Kirby provides the Str::replace() | Kirby CMS function:

$vimeoShortLink = Str::replace('https://vimeo.com/1234567890','https://vimeo.com/','');

This will replace the string https://vimeo.com/ from the string https://vimeo.com/1234567890 with nothing, hence remove it.

With Str::startsWith() | Kirby CMS you could check if the original string really starts with the part you want to remove.

Thanks I get it,
but should I use it in my page.php like :

  <?= $vimeoShortLink = Str::replace('https://vimeo.com/1234567890', 'https://vimeo.com/', '');
  echo $videoShortLink; ?>

Or should I use a page method?
Thanks !

I can’t tell, it depends on your use case.