Methods by type
String methods
FullThe everyday Str toolkit — case, trimming, indexing, splitting into pieces.
Str carries a large method set. These are the ones you reach for constantly: changing case, trimming, locating and slicing substrings, and breaking a string into characters or matches.
Length, case, reversal #
say "Hello".chars; say "Hello".uc; say "Hello".flip;
Output
5
HELLO
olleHTrim, index, substr #
trim removes surrounding whitespace, index finds a substring's position (zero-based), and substr extracts a slice by start and length.
say " hi ".trim;
say "hello".index("l");
say "hello".substr(1, 3);
Output
hi
2
ellcomb — break into pieces #
comb returns the matching pieces of a string: with no argument, each character; with a regex, each match.
say "hello".comb; say "a1b2c3".comb(/\d/);
Output
(h e l l o)
(1 2 3)trans — translate characters #
trans maps characters to replacements, like tr/// in other languages.
say "hello".trans("el" => "ip");
Output
hippoNotes #
.uc/.lc/.tc/.fccover upper, lower, title, and fold case;.wordcasetitle-cases each word..contains,.starts-with,.ends-withare the Boolean substring tests;.indicesfinds all positions..split(a routine and a method) breaks on a separator, while.combkeeps the matching parts — they are complements.