RegExp constructor

RegExp(String source, { bool multiLine: false bool caseSensitive: true @Since("2.4") bool unicode: false @Since("2.4") bool dotAll: false })

Constructs a regular expression.

Throws a FormatException if source is not valid regular expression syntax.

If multiLine is enabled, then ^ and $ will match the beginning and end of a line, in addition to matching beginning and end of input, respectively.

If caseSensitive is disabled, then case is ignored.

If unicode is enabled, then the pattern is treated as a Unicode pattern as described by the ECMAScript standard.

If dotAll is enabled, then the . pattern will match all characters, including line terminators.

Example:

var wordPattern = RegExp(r"(\w+)");
var bracketedNumberValue = RegExp("$key: \\[\\d+\\]");

Notice the use of a raw string in the first example, and a regular string in the second. Because of the many character classes used in regular expressions, it is common to use a raw string here, unless string interpolation is required.

Implementation

external factory RegExp(String source,
    {bool multiLine = false,
    bool caseSensitive = true,
    @Since("2.4") bool unicode = false,
    @Since("2.4") bool dotAll = false});