8

String Operations

Text manipulation with Ika / String domain

String Basics

// Create strings with double quotes
ayanmo greeting = "Kaabo!";
ayanmo name = "Orunmila";

// Unicode support (Yoruba diacritics)
ayanmo yoruba = "Ọlọ́run ṣe ọdún";

// Concatenation with +
ayanmo full = greeting + " " + name;
Irosu.fo(full);  // "Kaabo! Orunmila"

Ika / String Methods

Method Description Example
len(s) String length Ika.len("hello") → 5
uppercase(s) To uppercase Ika.uppercase("hi") → "HI"
lowercase(s) To lowercase Ika.lowercase("HI") → "hi"
trim(s) Remove whitespace Ika.trim(" hi ") → "hi"
split(s, delim) Split to list Ika.split("a,b,c", ",") → ["a","b","c"]
join(list, delim) Join list Ika.join(["a","b"], "-") → "a-b"
contains(s, sub) Check substring Ika.contains("hello", "ell") → otito
replace(s, old, new) Replace text Ika.replace("hello", "l", "L") → "heLLo"

Common Patterns

Parsing Input

ayanmo input = "  john, doe, 25  ";

// Clean and split
ayanmo cleaned = Ika.trim(input);
ayanmo parts = Ika.split(cleaned, ", ");

Irosu.fo("First: " + Ogunda.get(parts, 0));  // john
Irosu.fo("Last: " + Ogunda.get(parts, 1));   // doe
Irosu.fo("Age: " + Ogunda.get(parts, 2));    // 25

Building Strings

ayanmo words = ["Ifá", "is", "wisdom"];
ayanmo sentence = Ika.join(words, " ");
Irosu.fo(sentence);  // "Ifá is wisdom"

// With formatting
ayanmo name = "Adé";
ayanmo age = 30;
ayanmo msg = "Name: " + name + ", Age: " + age;
Irosu.fo(msg);  // "Name: Adé, Age: 30"

Validation

ise is_email(s) {
    padapọ Ika.contains(s, "@") && Ika.contains(s, ".");
}

Irosu.fo(is_email("test@example.com"));  // otito
Irosu.fo(is_email("not-an-email"));      // iro

String Transformation Pipeline

ayanmo raw = "  HELLO, WORLD!  ";

// Chain operations
ayanmo result = Ika.trim(raw);
ayanmo result = Ika.lowercase(result);
ayanmo result = Ika.replace(result, "!", "");
ayanmo result = Ika.replace(result, ",", "");

Irosu.fo(result);  // "hello world"

Practical Example: Slug Generator

ise slugify(title) {
    ayanmo slug = Ika.lowercase(title);
    ayanmo slug = Ika.replace(slug, " ", "-");
    ayanmo slug = Ika.replace(slug, "'", "");
    ayanmo slug = Ika.replace(slug, "!", "");
    padapọ slug;
}

Irosu.fo(slugify("Hello World!"));       // "hello-world"
Irosu.fo(slugify("Ifá's Wisdom"));       // "ifás-wisdom"