Skip to main content
trimprefix(str, prefix) returns str with the leading prefix removed. If str does not start with prefix, it is returned unchanged.

Signature

Example

Strip the v prefix from a git tag to get the bare version number for use in artifact names and package manifests:
v1.4.2 becomes 1.4.2.

Notes

  • Only the first occurrence is removed (i.e., if str starts with the prefix exactly once).
  • trimprefix removes a literal string match, not individual characters. Use trim for character-set stripping.