import std/io import std/string pub fn main :: -> () / { io.println (show (string.split "a,b,,c" ",")) io.println (show (string.to_int "-42") <> " " <> show (string.to_int "4x")) io.println ("[" <> string.trim " padded \n" <> "]") io.println (string.to_lower "Content-LENGTH") io.println ( show (string.byte_length "héllo") <> " bytes, " <> show (string.length "héllo") <> " chars" ) io.println ( show (string.starts_with "louise" "lou") <> " " <> show (string.ends_with "louise" "se") <> " " <> show (string.contains "louise" "uis") ) // string.find: the byte index of the first occurrence (Some) or None. io.println ( show (string.find "louise" "uis") <> " " <> show (string.find "louise" "e") <> " " <> show (string.find "louise" "x") ) io.println ( show (string.find "héllo" "llo") <> " " <> show (string.find "hello" "") <> " " <> show (string.find "aaaa" "aa") <> " " <> show (string.find "ab" "abc") ) // string.slice: by characters, bounds clamped to 0..length. io.println (string.slice "hello" 1 4) io.println (string.slice "héllo" 1 3 <> " " <> string.slice "日本語" 1 2) io.println ("[" <> string.slice "héllo" (-3) 100 <> "]") io.println ( "[" <> string.slice "héllo" 3 100 <> " " <> string.slice "héllo" 0 2 <> "]" ) io.println ( "[" <> string.slice "héllo" 4 2 <> string.slice "héllo" 5 5 <> string.slice "" 0 1 <> "]" ) } //> [a, b, , c] //> Ok(-42) Error(not an integer: "4x") //> [padded] //> content-length //> 6 bytes, 5 chars //> True True True //> Some(2) Some(5) None //> Some(3) Some(0) Some(0) None //> ell //> él 本 //> [héllo] //> [lo hé] //> []