2Elm.Native.Regex.make = function(elm) {
3 elm.Native = elm.Native || {};
4 elm.Native.Regex = elm.Native.Regex || {};
5 if (elm.Native.Regex.values) return elm.Native.Regex.values;
6 if ('values' in Elm.Native.Regex)
7 return elm.Native.Regex.values = Elm.Native.Regex.values;
9 var Maybe = Elm.Maybe.make(elm);
10 var JS = Elm.JavaScript.make(elm);
12 function escape(str) {
13 return str.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
15 function caseInsensitive(re) {
16 return new RegExp(re.source, 'gi');
19 return new RegExp(raw, 'g');
22 function contains(re, string) {
23 return re.test(JS.fromString(string));
26 function find(n, re, str) {
27 n = n.ctor === "All" ? Infinity : n._0;
30 var string = JS.fromString(str);
32 while (number++ < n && (result = re.exec(string))) {
33 var i = result.length - 1;
34 var subs = new Array(i);
36 var submatch = result[i];
37 subs[--i] = submatch === undefined
39 : Maybe.Just(JS.toString(submatch));
43 match: JS.toString(result[0]),
44 submatches: JS.toList(subs),
49 return JS.toList(out);
52 function replace(n, re, replacer, string) {
53 n = n.ctor === "All" ? Infinity : n._0;
55 function jsReplacer(match) {
56 if (count++ > n) return match;
57 var i = arguments.length-3;
58 var submatches = new Array(i);
60 var submatch = arguments[i];
61 submatches[--i] = submatch === undefined
63 : Maybe.Just(JS.toString(submatch));
65 return JS.fromString(replacer({
68 submatches:JS.toList(submatches),
73 return string.replace(re, jsReplacer);
76 function split(n, re, str) {
78 return JS.toList(JS.fromString(string).split(re));
80 var string = JS.fromString(str);
83 var start = re.lastIndex;
85 if (!(result = re.exec(string))) break;
86 out.push(string.slice(start, result.index));
89 out.push(string.slice(start));
90 return JS.toList(out);
93 return Elm.Native.Regex.values = {
95 caseInsensitive: caseInsensitive,
98 contains: F2(contains),
100 replace: F4(replace),
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list