Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1066)

Side by Side Diff: packages/quiver/lib/src/pattern/glob.dart

Issue 2989763002: Update charted to 0.4.8 and roll (Closed)
Patch Set: Removed Cutch from list of reviewers Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 Google Inc. All Rights Reserved. 1 // Copyright 2013 Google Inc. All Rights Reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and 12 // See the License for the specific language governing permissions and
13 // limitations under the License. 13 // limitations under the License.
14 14
15 part of quiver.pattern; 15 part of quiver.pattern;
16 16
17 // TODO(justin): add more detailed documentation and explain how matching 17 // TODO(justin): add more detailed documentation and explain how matching
18 // differs or is similar to globs in Python and various shells. 18 // differs or is similar to globs in Python and various shells.
19 /** 19 /// A [Pattern] that matches against filesystem path-like strings with
20 * A [Pattern] that matches against filesystem path-like strings with 20 /// wildcards.
21 * wildcards. 21 ///
22 * 22 /// The pattern matches strings as follows:
23 * The pattern matches strings as follows: 23 /// * The whole string must match, not a substring
24 * * The whole string must match, not a substring 24 /// * Any non wildcard is matched as a literal
25 * * Any non wildcard is matched as a literal 25 /// * '*' matches one or more characters except '/'
26 * * '*' matches one or more characters except '/' 26 /// * '?' matches exactly one character except '/'
27 * * '?' matches exactly one character except '/' 27 /// * '**' matches one or more characters including '/'
28 * * '**' matches one or more characters including '/'
29 */
30 class Glob implements Pattern { 28 class Glob implements Pattern {
31 final RegExp regex; 29 final RegExp regex;
32 final String pattern; 30 final String pattern;
33 31
34 Glob(String pattern) 32 Glob(String pattern)
35 : pattern = pattern, 33 : pattern = pattern,
36 regex = _regexpFromGlobPattern(pattern); 34 regex = _regexpFromGlobPattern(pattern);
37 35
38 Iterable<Match> allMatches(String str, [int start = 0]) => 36 Iterable<Match> allMatches(String str, [int start = 0]) =>
39 regex.allMatches(str, start); 37 regex.allMatches(str, start);
(...skipping 27 matching lines...) Expand all
67 } 65 }
68 } else if (c == '?') { 66 } else if (c == '?') {
69 sb.write('[^/]'); 67 sb.write('[^/]');
70 } else { 68 } else {
71 sb.write(c); 69 sb.write(c);
72 } 70 }
73 } 71 }
74 sb.write(r'$'); 72 sb.write(r'$');
75 return new RegExp(sb.toString()); 73 return new RegExp(sb.toString());
76 } 74 }
OLDNEW
« no previous file with comments | « packages/quiver/lib/src/iterables/zip.dart ('k') | packages/quiver/lib/src/streams/collect.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698