Movatterモバイル変換


[0]ホーム

URL:


menu
  1. Dart
  2. dart:core
  3. String
  4. startsWith abstract method
startsWith
description

startsWith abstract method

boolstartsWith(
  1. Patternpattern, [
  2. intindex =0
])

Whether this string starts with a match ofpattern.

const string = 'Dart is open source';print(string.startsWith('Dar')); // trueprint(string.startsWith(RegExp(r'[A-Z][a-z]'))); // true

Ifindex is provided, this method checks if the substring startingat that index starts with a match ofpattern:

const string = 'Dart';print(string.startsWith('art', 0)); // falseprint(string.startsWith('art', 1)); // trueprint(string.startsWith(RegExp(r'\w{3}'), 2)); // false

index must not be negative or greater thanlength.

ARegExp containing '^' does not match if theindex is greater thanzero and the regexp is not multi-line.The pattern works on the string as a whole, and does not extracta substring starting atindex first:

const string = 'Dart';print(string.startsWith(RegExp(r'^art'), 1)); // falseprint(string.startsWith(RegExp(r'art'), 1)); // true

Implementation

bool startsWith(Pattern pattern, [int index = 0]);
  1. Dart
  2. dart:core
  3. String
  4. startsWith abstract method
String class

[8]ページ先頭

©2009-2025 Movatter.jp