substring Summary Extracts a substring. Signatures Click on a signature to select it and view its documentation. public string substring(int indexA) public string substring(int indexA, int indexB) Usage public string substring(int indexA) public string substring(int indexA, int indexB) Returns The extracted substring. Parameters indexA The zero-based index to begin extracting the substring. Parameters indexA The zero-based index to begin extracting the substring. indexB The zero-based index to stop extracting the substring. Description Extracts a substring from the specified position until the end of the string. If the specified position is less than zero, it will be treated as zero. If the specified position is higher than the string length, the specified position will be treated as the string length. Extracts a substring from the specified beginning position to the specified ending position. If the specified beginning position and ending position are the same, an empty string will be returned. If either specified position is less than zero, it will be treated as zero. If either specified position is higher than the string length, it will be treated as the string length. Examples Extracting substrings from a position until the end of the string 12345import System; string abc = "abc";Console.log(abc.substring(1)); // "bc"Console.log(abc.substring(2)); // "c" Extracting a substring between two positions 1234import System; string text = "The quick brown fox.";Console.log(text.substring(0, 9)); // "The quick" Share HTML | BBCode | Direct Link