Dart Analyze logoDart Analyze/
DRT-W1035

Use valid regular expression syntaxDRT-W1035

Major severityMajor
Bug Risk categoryBug Risk

DO use valid regular expression syntax when creating regular expression instances.

Regular expressions created with invalid syntax will throw a FormatException at runtime so should be avoided.

BAD:

print(RegExp(r'(').hasMatch('foo()'));

GOOD:

print(RegExp(r'\(').hasMatch('foo()'));