slice

Summary

Extracts a substring from the given position(s).

Signatures

Click on a signature to select it and view its documentation.

Usage

public string slice(int begin)

Returns

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.

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.

Examples

Basic Usage
1
2
3
4
import 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
1
2
3
4
import System;
 
string message = "The quick brown fox jumped.";
Console.log(message.slice(-7)); // "jumped."

Share

HTML | BBCode | Direct Link