kgaoganyaMokwalo
Splits text into a list of pieces.
When you give nothing else, the text is split at every stretch of whitespace — a space, a tab, or a new line.
When you give a second value, every single character in it is a splitting place of its own. So kgaoganyaMokwalo("a;b,c", ";,") splits on ; and on ,, returning three pieces.
All the pieces come back as text. When you want numbers, pass them through palotlalo or palophatlo.
Note: p5 2.x removed split, join, trim and match. kgaoganyaMokwalo is the one that remains, and JavaScript's own built-in functions still work.
Syntax
Section titled “Syntax”kgaoganyaMokwalo(boleng, dikgaolo)Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
boleng | mokwalo | The text to split. |
dikgaolo (optional) | mokwalo | The delimiter characters. Each single character works on its own. Defaults to whitespace when omitted. |
Examples
Section titled “Examples”tiro setaLoeto() {
thalaKanefase(400, 400);
bokamorago(220);
tlogelaMothalo();
diri boleng = "240 120 40";
diri dikarolo = kgaoganyaMokwalo(boleng);
kwala(dikarolo);
diri r = palotlalo(dikarolo[0]);
diri g = palotlalo(dikarolo[1]);
diri b = palotlalo(dikarolo[2]);
tlatsaMmala(r, g, b);
kgolokwe(200, 200, 240);
}tiro setaLoeto() {
thalaKanefase(400, 400);
bokamorago(220);
tlogelaMothalo();
diri dikarolo = kgaoganyaMokwalo("60;120,180", ";,");
kwala(dikarolo);
diri x = 90;
gopheta (metlha karolo mo dikarolo) {
tlatsaMmala(0, 120, 200);
kgolokwe(x, 200, palotlalo(karolo));
x = x + 110;
}
}