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:
var r = RegExp(r'(');
Common fixes
#Fix the regular expression:
var r = RegExp(r'\(');
Unless stated otherwise, the documentation on this site reflects Dart 3.9.2. Page last updated on 2025-9-1. View source or report an issue.