OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
2 // for details. All rights reserved. Use of this source code is governed by a | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 part of dart.core; | |
6 | |
7 /** | |
8 * A regular expression pattern. | |
9 * | |
10 * Regular expressions are [Pattern]s, and can as such be used to match strings | |
11 * or parts of strings. | |
12 * | |
13 * Dart regular expressions have the same syntax and semantics as | |
14 * JavaScript regular expressions. See | |
15 * <http://ecma-international.org/ecma-262/5.1/#sec-15.10> | |
16 * for the specification of JavaScript regular expressions. | |
17 * | |
18 * [firstMatch] is the main implementation method that applies a regular | |
19 * expression to a string and returns the first [Match]. All | |
20 * other methods in [RegExp] can build on it. | |
21 * | |
22 * Use [allMatches] to look for all matches of a regular expression in | |
23 * a string. | |
24 * | |
25 * The following example finds all matches of a regular expression in | |
26 * a string. | |
27 * | |
28 * RegExp exp = new RegExp(r"(\w+)"); | |
29 * String str = "Parse my string"; | |
30 * Iterable<Match> matches = exp.allMatches(str); | |
31 * | |
32 * Note the use of a _raw string_ (a string prefixed with `r`) | |
33 * in the example above. Use a raw string to treat each character in a string | |
34 * as a literal character. | |
35 */ | |
36 abstract class RegExp implements Pattern { | |
37 /** | |
38 * Constructs a regular expression. | |
39 * | |
40 * Throws a [FormatException] if [source] is not valid regular | |
41 * expression syntax. | |
42 */ | |
43 external factory RegExp(String source, {bool multiLine: false, | |
44 bool caseSensitive: true}); | |
45 | |
46 /** | |
47 * Searches for the first match of the regular expression | |
48 * in the string [input]. Returns `null` if there is no match. | |
49 */ | |
50 Match firstMatch(String input); | |
51 | |
52 /** | |
53 * Returns an iterable of the matches of the regular expression on [input]. | |
54 * | |
55 * If [start] is provided, only start looking for matches at `start`. | |
56 */ | |
57 Iterable<Match> allMatches(String input, [int start = 0]); | |
58 | |
59 /** | |
60 * Returns whether the regular expression has a match in the string [input]. | |
61 */ | |
62 bool hasMatch(String input); | |
63 | |
64 /** | |
65 * Returns the first substring match of this regular expression in [input]. | |
66 */ | |
67 String stringMatch(String input); | |
68 | |
69 /** | |
70 * The source regular expression string used to create this `RegExp`. | |
71 */ | |
72 String get pattern; | |
73 | |
74 /** | |
75 * Whether this regular expression matches multiple lines. | |
76 * | |
77 * If the regexp does match multiple lines, the "^" and "$" characters | |
78 * match the beginning and end of lines. If not, the character match the | |
79 * beginning and end of the input. | |
80 */ | |
81 bool get isMultiLine; | |
82 | |
83 /** | |
84 * Whether this regular expression is case sensitive. | |
85 * | |
86 * If the regular expression is not case sensitive, it will match an input | |
87 * letter with a pattern letter even if the two letters are different case | |
88 * versions of the same letter. | |
89 */ | |
90 bool get isCaseSensitive; | |
91 } | |
OLD | NEW |