Skip to main content

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'\(');