string

Generated by tinox doc

String utility functions as static Strings:: helpers — case conversion, trim, contains/startsWith/endsWith, substring, repeat, replace, reverse, split/join — a companion to String's own built-in instance methods.

String utils

import tinox.core.string;

class Main
{
    fnc main() -> Int32
    {
        let s: String = "  Hello, Tinox!  ";
        println(Strings::trim(s));
        println(Strings::toUpperCase(Strings::trim(s)));
        println(Strings::contains(s, "Tinox").toString());

        let parts: List<String> = Strings::split("a,b,c", ",");
        println(Strings::join(parts, " | "));

        println(Strings::repeat("ab", 3));
        println(Strings::replace("foo bar foo", "foo", "baz"));

        return 0;
    }
}

class Strings

* String utility class providing common string operations * including inspection, transformation, splitting, and formatting

Methods

fn length(s: String) → Int64
* Returns the length of the string * * @param s the input string * @return the number of characters in the string
fn isEmpty(s: String) → Bool
* Checks if the string is empty * * @param s the input string * @return true if the string has zero length
fn toUpperCase(s: String) → String
* Converts all characters to uppercase * * @param s the input string * @return a new string with all uppercase characters
fn toLowerCase(s: String) → String
* Converts all characters to lowercase * * @param s the input string * @return a new string with all lowercase characters
fn trim(s: String) → String
* Removes leading and trailing whitespace * * @param s the input string * @return a new string with whitespace removed from both ends
fn contains(haystack: String, needle: String) → Bool
* Checks if the haystack contains the needle * * @param haystack the string to search in * @param needle the substring to search for * @return true if needle is found in haystack
fn startsWith(s: String, prefix: String) → Bool
* Checks if the string starts with the given prefix * * @param s the input string * @param prefix the prefix to check for * @return true if s starts with prefix
fn endsWith(s: String, suffix: String) → Bool
* Checks if the string ends with the given suffix * * @param s the input string * @param suffix the suffix to check for * @return true if s ends with suffix
fn substring(s: String, start: Int64, end: Int64) → String
* Extracts a substring from start to end (exclusive) * * @param s the input string * @param start the starting index (inclusive) * @param end the ending index (exclusive) * @return the extracted substring
fn repeat(s: String, count: Int64) → String
* Repeats the string count times * * @param s the string to repeat * @param count the number of repetitions (must be non-negative) * @return a new string with s repeated count times
fn replace(s: String, old: String, repl: String) → String
* Replaces all occurrences of old with new * * @param s the input string * @param old the substring to replace * @param new the replacement substring * @return a new string with all occurrences replaced
fn reverse(s: String) → String
* Reverses the characters in the string * * @param s the input string * @return a new string with characters in reverse order
fn split(s: String, delimiter: String) → List<String>
* Splits the string by the given delimiter * * @param s the input string * @param delimiter the delimiter to split on * @return a list of substrings
fn join(parts: List<String>, separator: String) → String
* Joins a list of strings with a separator * * @param parts the list of strings to join * @param separator the string to insert between parts * @return the joined string
fn intToString(n: Int64) → String
* Converts an integer to its string representation * * @param n the integer to convert * @return the string representation of n
fn floatToString(f: Float64) → String
* Converts a float to its string representation * * @param f the float to convert * @return the string representation of f