September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
17
Task/Multisplit/Zkl/multisplit-1.zkl
Normal file
17
Task/Multisplit/Zkl/multisplit-1.zkl
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
fcn multisplit(text, sep){
|
||||
lastmatch := i := 0; matches := List();
|
||||
while(i < text.len()){
|
||||
foreach j,s in ([0..].zip(sep)){
|
||||
if(i == text.find(s,i)){
|
||||
if(i > lastmatch) matches.append(text[lastmatch,i-lastmatch]);
|
||||
matches.append(T(j,i)); # Replace the string containing the matched separator with a tuple of which separator and where in the string the match occured
|
||||
lastmatch = i + s.len();
|
||||
i += s.len()-1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
if(i > lastmatch) matches.append(text[lastmatch,i-lastmatch]);
|
||||
return(matches);
|
||||
}
|
||||
2
Task/Multisplit/Zkl/multisplit-2.zkl
Normal file
2
Task/Multisplit/Zkl/multisplit-2.zkl
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
multisplit("a!===b=!=c", T("==", "!=", "=")).println();
|
||||
multisplit("a!===b=!=c", T("!=", "==", "=")).println();
|
||||
Loading…
Add table
Add a link
Reference in a new issue