tangled
alpha
login
or
join now
kitten.sh
/
reghex
0
fork
atom
Mirror: The magical sticky regex-based parser generator 🧙
0
fork
atom
overview
issues
pulls
pipelines
Use RegExp#test instead of #exec
kitten.sh
5 years ago
1d76d269
b7ba1e93
+10
-5
1 changed file
expand all
collapse all
unified
split
src
core.js
+10
-5
src/core.js
···
24
24
let match;
25
25
if (isStickySupported) {
26
26
pattern.lastIndex = state.index;
27
27
-
match = pattern.exec(state.input);
28
28
-
state.index = pattern.lastIndex;
27
27
+
if (pattern.test(state.input)) {
28
28
+
match = state.input.slice(state.index, pattern.lastIndex);
29
29
+
state.index = pattern.lastIndex;
30
30
+
}
29
31
} else {
30
32
pattern.lastIndex = 0;
31
31
-
match = pattern.exec(state.input.slice(state.input));
32
32
-
state.index += pattern.lastIndex;
33
33
+
if (pattern.test(state.input.slice(state.index))) {
34
34
+
const lastIndex = state.index + pattern.lastIndex;
35
35
+
match = state.input.slice(state.index, lastIndex);
36
36
+
state.index = lastIndex;
37
37
+
}
33
38
}
34
39
35
35
-
return match && match[0];
40
40
+
return match;
36
41
};
37
42
38
43
export const tag = (array, tag) => {