Removes a prefix from the beginning of a string. If the string does not start with the prefix, it is returned unchanged.
trimPrefix(input, prefix)
or chained:
<string>.trimPrefix(prefix)
input (string, optional when chained) - The string to trim.
string
prefix (string) - The prefix to remove.
Function call
trimPrefix("hello world", "hello ") // "world"
Chained usage
"foobar".trimPrefix("foo") // "bar"
No match — string unchanged
"foobar".trimPrefix("xyz") // "foobar"
CLI usage — strip a URL prefix
Last updated 3 months ago
$ echo '{"url": "https://example.com/path"}' | dasel -i json 'url.trimPrefix("https://")' example.com/path