Syntax

Platform.Function.Substring(value, start [, length])
2–3 arguments

Parameters

Name Type Required Description
value string Yes Source string
start number Yes Starting position (1-based, not 0-based!)
length number No Number of characters to extract (if omitted, extracts to end of string)

Important: Substring uses 1-based indexing — position 1 is the first character. This differs from JavaScript’s native str.substring(0).

Examples

var str = "Hello, World!";

// Extract from position 8, length 5
var sub1 = Platform.Function.Substring(str, 8, 5);
Write(sub1); // "World"

// Extract from position 1, length 5
var sub2 = Platform.Function.Substring(str, 1, 5);
Write(sub2); // "Hello"

// Extract from position 8 to end
var sub3 = Platform.Function.Substring(str, 8);
Write(sub3); // "World!"

// Get domain from email
var email = "jane@example.com";
var atPos = Platform.Function.IndexOf(email, "@");
var domain = Platform.Function.Substring(email, atPos + 2);
Write(domain); // "example.com"

See Also

See Also