iregexp

A Dart implementation of RFC 9485 for interoperable regular expressions.

IRegexp(pattern) validates the pattern at construction and throws a FormatException if it is invalid. Reuse the same instance to match multiple strings. Patterns and input strings are expected to contain well-formed Unicode.

Use matches to check the entire input or matchesSubstring to search anywhere in the input.

import 'package:iregexp/iregexp.dart';

void main() {
  final iRegexp = IRegexp(r'[0-9]+\.[0-9]+\.[0-9]+');
  print(iRegexp.matches('1.2.3')); // true
  print(iRegexp.matches('v1.2.3')); // false
  print(iRegexp.matchesSubstring('v1.2.3')); // true
}

Use toRegExp() or toSubstringRegExp() to get a Dart RegExp for the corresponding matching mode. Both preserve groups from the pattern and add no capture groups of their own.

Libraries

iregexp