A regular expression pattern.

Regular expressions are Patterns, and can as such be used to match strings or parts of strings.

Dart regular expressions have the same syntax and semantics as JavaScript regular expressions. See http://ecma-international.org/ecma-262/5.1/#sec-15.10 for the specification of JavaScript regular expressions.

firstMatch is the main implementation method that applies a regular expression to a string and returns the first Match. All other methods in RegExp can build on it.

Use allMatches to look for all matches of a regular expression in a string.

The following example finds all matches of a regular expression in a string.

RegExp exp = new RegExp(r"(\w+)");
String str = "Parse my string";
Iterable<Match> matches = exp.allMatches(str);


RegExp(String source, {bool multiLine: false, bool caseSensitive: true})

Constructs a regular expression.



hashCode int

Get a hash code for this object.

read-only, inherited
isCaseSensitive bool

Whether this regular expression is case sensitive.

isMultiLine bool

Whether this regular expression matches multiple lines.

pattern String

The source regular expression string used to create this RegExp.

runtimeType Type

A representation of the runtime type of the object.

read-only, inherited


operator ==(other) bool

The equality operator.



allMatches(String input, [int start = 0]) Iterable<Match>

Returns an iterable of the matches of the regular expression on input.

firstMatch(String input) Match

Searches for the first match of the regular expression in the string input. Returns null if there is no match.

hasMatch(String input) bool

Returns whether the regular expression has a match in the string input.

matchAsPrefix(String string, [int start = 0]) Match

Match this pattern against the start of string.

noSuchMethod(Invocation invocation) → dynamic

noSuchMethod is invoked when users invoke a non-existent method on an object. The name of the method and the arguments of the invocation are passed to noSuchMethod in an Invocation. If noSuchMethod returns a value, that value becomes the result of the original invocation.

stringMatch(String input) String

Returns the first substring match of this regular expression in input.

toString() String

Returns a string representation of this object.