IndexOf

This function returns the position of the first occurrence of a specified value in a string. The index numbering starts at 1.

Arguments

IndexOf(1,2)

Ordinal Type Required Description
1 String True String to search
2 String True String value to find

Example

%%[

var @fullName
var @firstName

set @fullName = AttributeValue("fullName") /* value from attribute or DE column in send context */
set @fullName = "Dale Cameron" /* or a literal value */

if indexOf(@fullName, " ") > 0 then
  set @firstName = Substring(@fullName,1, Subtract(IndexOf(@fullName," "),1))
endif

]%%
fullName: %%=v(@fullName)=%%
<br>firstName: %%=v(@firstName)=%%

Output

fullName: Dale Cameron
firstName: Dale