Skip to content
Snippets Groups Projects
Commit 51fa2400 authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Improved splitting behaviour for complex regexps

parent 6017dc37
No related branches found
No related tags found
No related merge requests found
......@@ -33,11 +33,24 @@ class StateHandler extends Component {
}
parse(options = {}) {
function split(str, sep, n) {
const out = [];
let lastIndex = 0;
let index;
while (n-- > 1 && (index = str.indexOf(sep, lastIndex)) >= 0) {
out.push(str.slice(lastIndex, index));
lastIndex = index + sep.length;
}
out.push(str.slice(lastIndex));
return out;
}
let query = [];
const words = this.state.split(" ");
words.forEach((word) => {
const parts = word.split(":");
if (parts.length === 2 && [
const parts = split(word, ":", 2);
console.log(parts);
if ([
"sender",
"buffer",
"network",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment