IndexOf
→ numberReturns the zero-based position of the first occurrence of a substring within a string. Returns -1 if not found.
Available in:
Email
CloudPage
Automation
Triggered Send
Syntax
Platform.Function.IndexOf(value, search)
2 arguments
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
value |
string | Yes | String to search in |
search |
string | Yes | Substring to find |
Examples
var str = "hello@example.com";
var atPos = Platform.Function.IndexOf(str, "@");
Write(atPos); // 5
// Check if substring exists
if (Platform.Function.IndexOf(str, "@") > -1) {
Write("Contains @");
}
// Find domain part
var domain = Platform.Function.Substring(str, atPos + 2);
// atPos is 0-based, Substring is 1-based, so +2 to skip "@"