dart-sdk/tests/language/reg_exp/reg_exp4_test.dart
Robert Nystrom 222248b29e Migrate language_2/reg_exp to NNBD.
Change-Id: I662add43926c09735f7ae3899567f5df085ff6a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150465
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2020-06-09 18:45:33 +00:00

27 lines
810 B
Dart

// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// Dart test for testing regular expressions in Dart.
class RegEx2Test {
static void testMain() {
final helloPattern = new RegExp("with (hello)");
String s = "this is a string with hello somewhere";
Match? match = helloPattern.firstMatch(s);
if (match != null) {
print("got match");
int groupCount = match.groupCount;
print("groupCount is $groupCount");
print("group 0 is ${match.group(0)}");
print("group 1 is ${match.group(1)}");
} else {
print("match not round");
}
print("done");
}
}
main() {
RegEx2Test.testMain();
}