RegExp constructor Null safety
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:
final wordPattern = RegExp(r'(\w+)');
final digitPattern = RegExp(r'(\d+)');
Notice the use of a raw string in the first example, and a regular
string in the second. Because of the many escapes, like \d
, 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});