token Summary Gets the token at the specified index. Signatures Click on a signature to select it and view its documentation. public string token(string delimiter, int index) public string token(string delimiter, int index, string defaultValue) public string? token(string delimiter, int index, string? defaultValue) Usage public string token(string delimiter, int index) public string token(string delimiter, int index, string defaultValue) public string? token(string delimiter, int index, string? defaultValue) Parameters delimiter The string or character that separates each token. index The token index to return. Parameters delimiter The string or character that separates each token. index The token index to return. defaultValue The default value to return if the token does not exist at the specified index. Parameters delimiter The string or character that separates each token. index The token index to return. defaultValue The default value to return if the token does not exist at the specified index. Description If there is no token at the specified index, an empty string is returned. If there is no token at the specified index, the default value is returned. If there is no token at the specified index, the default value is returned. Examples Get email domain without manually tokenizing a string with `System.String.split` 123import System; string str = "foo Basic Usage 123456789import System; string a = "a:b:c".token(":", 0); // "a"string b = "a:b:c".token(":", 1); // "b"string d = "a:b:c".token(":", 4, "Does not exist."); // "Does not exist." Console.log(a); // "a"Console.log(b); // "b"Console.log(d); // "Does not exist." Basic Usage 123456789import System; string a = "a:b:c".token(":", 0); // "a"string b = "a:b:c".token(":", 1); // "b"string d = "a:b:c".token(":", 4, null); // null Console.log(a); // "a"Console.log(b); // "b"Console.log(d); // null Share HTML | BBCode | Direct Link