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');
18 function pattern(raw) {
19 return new RegExp(raw, 'g');
22 function contains(re, string) {
23 return re.test(JS.fromString(string));
26 function findAll(re, string) {
27 return find(Infinity, re, string);
29 function find(n, re, str) {
32 var string = JS.fromString(str);
34 while (number++ < n && (result = re.exec(string))) {
35 var i = result.length - 1;
36 var subs = new Array(i);
38 var submatch = result[i];
39 subs[--i] = submatch === undefined
41 : Maybe.Just(JS.toString(submatch));
45 match: JS.toString(result[0]),
46 submatches: JS.toList(subs),
51 return JS.toList(out);
54 function replaceAll(re, replacer, string) {
55 return replace(Infinity, re, replacer, string);
57 function replace(n, re, replacer, string) {
59 function jsReplacer(match) {
60 if (count++ > n) return match;
61 var i = arguments.length-3;
62 var submatches = new Array(i);
64 var submatch = arguments[i];
65 submatches[--i] = submatch === undefined
67 : Maybe.Just(JS.toString(submatch));
69 return JS.fromString(replacer({
72 submatches:JS.toList(submatches),
77 return string.replace(re, jsReplacer);
80 function split(re, string) {
81 return JS.toList(JS.fromString(string).split(re));
83 function splitN(n, re, str) {
84 var string = JS.fromString(str);
87 var start = re.lastIndex;
89 if (!(result = re.exec(string))) break;
90 out.push(string.slice(start, result.index));
93 out.push(string.slice(start));
94 return JS.toList(out);
97 return Elm.Native.Regex.values = {
99 caseInsensitive: caseInsensitive,
102 contains: F2(contains),
103 findAll: F2(findAll),
106 replaceAll: F3(replaceAll),
107 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