trimprefix(str, prefix) returns str with the leading prefix removed. If str does not start with prefix, it is returned unchanged.
Signature
Example
Strip thev 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
strstarts with the prefix exactly once). trimprefixremoves a literal string match, not individual characters. Usetrimfor character-set stripping.