Articles in this section

removefirst helper

The removefirst helper removes the first occurrence of a specified substring from a string, leaving all later occurrences unchanged. Use it to strip a known prefix or leading marker from a field value.

Syntax

{{removefirst str substring}}

str -- The input string. Required.

substring -- The substring to remove. Required. Matching is case-sensitive: "A" and "a" are treated as different values.

Examples

Remove the first occurrence of a character

{{removefirst record.text "a"}}

Input:

{ "record": { "text": "a b a b a b" } }

Output: b a b a b

The first "a" is removed. The remaining two instances are preserved.

Remove the first occurrence of a word

{{removefirst record.note "Order"}}

Input:

{ "record": { "note": "Order Order Order" } }

Output: Order Order

Only the first "Order" is removed. Note that the removal leaves a leading space -- trim the output if needed.

Usage notes

  • Only the first match is removed. All subsequent occurrences remain unchanged.
  • Matching is case-sensitive: "Order" and "order" are treated as different substrings.
  • Removing a substring may leave a leading or internal space. Use a trim helper to clean up whitespace if needed.
  • To remove all occurrences instead, use {{regexReplace field "" "substring" "g"}}.