Substring()

Returns a portion of a string, beginning at a specified character position. You can optionally specify the length of the substring to return.

Availability 

Marketing Cloud Engagement ✅ Yes
Marketing Cloud Next ✅ Yes

This function became available in Marketing Cloud Next during the Summer ’26 release (API version 67.0).

Syntax 

1Substring(sourceString,
2          startPosition,
3          substringLength)

The Substring() function has three parameters:

  • sourceString (string): Required. The string that contains the substring you want to identify.
  • startPosition (number): Required. The character position to begin the substring. If the specified character position exceeds the length of sourceString, the function returns an empty string.
  • substringLength (number): The number of characters to return after the initial character. If you don’t specify a length, the substring continues to the end of the string.

Usage 

This example uses the Substring() function to remove part of a string of text and return the result.

1%%[
2  Var @rewardsSegment, @rewardsTier
3  Set @rewardsSegment = "0312F-Gold"
4  Set @rewardsTier = Substring(@rewardsSegment, 7)
5]%%
6<p>Thank you for being a %%=v(@rewardsTier)=%% rewards member!</p>

The example returns the specified substring.

1Thank you for being a Gold rewards member!