Articles in this section

occurrences helper

The occurrences helper returns the number of times a given substring appears within an input string. It’s useful for counting keyword matches, delimiters, or repeated text patterns.

Usage

{{occurrences str substring}}
  • str (required): The input string to search

  • substring (required): The substring to count occurrences of

Examples

Count how many times a word appears

{{occurrences record.text "foo"}}

Input:

{
  "record": {
    "text": "foo bar foo bar baz"
  }
}

Output:

2

Count delimiter occurrences

{{occurrences record.path "/"}}

Input:

{
  "record": {
    "path": "/api/v1/resource/item"
  }
}

Output:

4

Count character appearances

{{occurrences record.name "a"}}

Input:

{
  "record": {
    "name": "Banana"
  }
}

Output:

3

Tip

  • Matching is case-sensitive by default ("Foo""foo").

  • Overlapping matches aren’t counted separately.

  • Use it to validate input patterns or measure frequency of specific tokens in text fields.