Skip to content

Bars Specification 0.1.0 — Transform: replace_last

Category: string · Since: 0.1.0

Replaces only the last occurrence of a substring.

Replaces only the last occurrence of old with new in the string-coerced input. An empty old appends new at the end of the input.

Input coercion: string

Arguments

Name Type Optional Default
old string no
new string no

Arity: 2–2

Worked examples

{{ phrase | replace_last: "world" "Mark" }}

hello world, big Mark
{{ phrase | replace_last: "world" "Mark" | upcase }}

HELLO MARK

Full fixture: transforms/transform-replace_last.json