Handlebars indexOf
Handlebars indexOf: returns the 1-based position of a substring within a string (case-insensitive).
Next
Runtime verified
Test scripts included
Returns the 1-based position of a substring within a string (case-insensitive).
Syntax
{{indexOf subject search}}
Returns integer.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
subject |
string | Yes | String to search. |
search |
string | Yes | The string to find. |
Example
Tested in a Marketing Cloud Next email on 2026-11-22:
{{indexOf "Hello World" "world"}}renders7, as documented.{{indexOf "abc" "z"}}renders0, as documented.
Show Next test script
Marketing Cloud Next
Works as documented
Every tested call rendered the documented result. Tested 2026-11-22 by rendering in a Marketing Cloud Next email.
See also
- AMPscript
IndexOf— does a similar job in AMPscript, with a different call shape - Official reference