Skip to content

Bars Specification 0.1.0 — Transform: replace_first

Category: string · Since: 0.1.0

Replaces only the first occurrence of a substring.

Replaces only the first occurrence of old with new in the string-coerced input. An empty old inserts new at the start of the input.

Input coercion: string

Arguments

Name Type Optional Default
old string no
new string no

Arity: 2–2

Worked examples

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

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

Mark WORLD

Full fixture: transforms/transform-replace_first.json