Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,46 @@
|
|||
import extensions;
|
||||
import extensions'routines;
|
||||
import system'collections;
|
||||
import system'routines;
|
||||
import system'text;
|
||||
|
||||
extension op : String
|
||||
{
|
||||
tokenize(separator,escape)
|
||||
{
|
||||
auto buffer := new TextBuilder();
|
||||
auto list := new ArrayList();
|
||||
|
||||
bool escaping := false;
|
||||
self.forEach:(ch)
|
||||
{
|
||||
if (escaping)
|
||||
{
|
||||
buffer.write:ch;
|
||||
escaping := false
|
||||
}
|
||||
else if (ch == escape)
|
||||
{
|
||||
escaping := true
|
||||
}
|
||||
else if (ch == separator)
|
||||
{
|
||||
list.append(buffer.Value);
|
||||
buffer.clear()
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer.write:ch
|
||||
}
|
||||
};
|
||||
|
||||
^ list
|
||||
}
|
||||
}
|
||||
|
||||
const string testcase = "one^|uno||three^^^^|four^^^|^cuatro|";
|
||||
|
||||
public program()
|
||||
{
|
||||
testcase.tokenize("|", "^").forEach:printingLn
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue