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'\(');
Was this page's content helpful?
Thank you for your feedback!
Provide details Thank you for your feedback! Please let us know what we can do to improve.
Provide details Unless stated otherwise, the documentation on this site reflects Dart 3.8.1. Page last updated on 2025-05-08. View source or report an issue.