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 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);
Note the use of a raw string (a string prefixed with r
)
in the example above. Use a raw string to treat each character in a string
as a literal character.
RegExp
.
input
. [...]
input
. Returns null
if there is no match.
input
.
input
.
string
. [...]