valid_regexps
Invalid regular expression syntax.
Description
#The analyzer produces this diagnostic when the string passed to the
default constructor of the class RegExp
doesn't contain a valid regular
expression.
A regular expression created with invalid syntax will throw a
FormatException
at runtime.
Example
#The following code produces this diagnostic because the regular expression isn't valid:
dart
var r = RegExp(r'(');
Common fixes
#Fix the regular expression:
dart
var r = RegExp(r'\(');
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。