> ## Documentation Index
> Fetch the complete documentation index at: https://errand.nuvrel.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# trimprefix

> Remove a specific prefix from a string.

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

## Signature

```
trimprefix(str string, prefix string) string
```

## Example

Strip the `v` prefix from a git tag to get the bare version number for use in artifact names and package manifests:

```hcl theme={null}
variable "tag" {
  description = "Git release tag (e.g. v1.4.2)"
  type        = string
}

computed "version" {
  description = "Bare version number without the v prefix"
  expression  = trimprefix(var.tag, "v")
}

task "package" {
  description = "Build release archives with the bare version"
  commands = [
    "go build -ldflags \"-X main.version=${computed.version}\" -o bin/app ./cmd/app",
    "tar -czf myapp-${computed.version}-linux-amd64.tar.gz bin/app",
  ]
}
```

`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`](/functions/string/trim) for character-set stripping.
