Dart-programming-substring-method
提供:Dev Guides
Dartプログラミング-サブストリングメソッド
startIndex(両端を含む)からendIndex(排他的)に及ぶこの文字列の部分文字列を返します。
構文
substring(int startIndex, [ int endIndex ])
パラメーター
- startIndex -抽出を開始するインデックス(包括的)。
- endIndex -抽出を停止するインデックス(排他的)。
注-インデックスはゼロベースです。つまり、最初の文字のインデックスは0になります。
戻りタイプ
文字列を返します。
例
void main() {
String str1 = "Hello World";
print("New String: ${str1.substring(6)}");
//from index 6 to the last index
print("New String: ${str1.substring(2,6)}");
//from index 2 to the 6th index
}
次の output -が生成されます。
New String: World
New String: llo