Substring

This function returns a portion of the specified string starting at a certain character position and no longer than the specified length. If the specified character position is more than the length of the specified string, the function returns an empty string.

Arguments

Substring(1,2,3)

Ordinal Type Required Description
1 String True The string from which to extract a portion
2 Number True Starting position of substring
3 Number False Length of substring

Example

%%[

var @fullName
var @firstName

set @fullName = AttributeValue("fullName") /* value from attribute or DE column in send context */
set @fullName = "Curt Harris" /* 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: Curt Harris
firstName: Curt