slice Summary Extracts a substring from the given position(s). Signatures Click on a signature to select it and view its documentation. public string slice(int begin) public string slice(int begin, int end) Usage public string slice(int begin) public string slice(int begin, int end) Returns The extracted substring. The extracted substring. Parameters begin The zero-based index to begin extraction. If this is a negative number, the index is determined relative to the end of the string. Parameters begin The zero-based index to begin extraction. If this is a negative number, the index is determined relative to the end of the string. end The zero-based index to end extraction. If this is a negative number, the index is determined relative to the end of the string. Description Extracts the substring from a given index until the end of the string. If the index provided is a negative number, the index is determined by counting backwards beginning from the end of the string. Thus, an index of -3 means three characters before the end of the string. Extracts the substring from a starting index until the ending index. If an index is a negative number, the index is determined by counting backwards beginning from the end of the string. Thus, an index of -3 means three characters before the end of the string. Examples Basic Usage 1234import System; string message = "The quick brown fox jumped.";Console.log(message.slice(5)); // "uick brown fox jumped." Get Substring Starting from the End of a String 1234import System; string message = "The quick brown fox jumped.";Console.log(message.slice(-7)); // "jumped." Slicing Off the End of a String 1234import System; string message = "The quick brown fox jumped.";Console.log(message.slice(0, -3)); // "The quick brown fox jump" Share HTML | BBCode | Direct Link