Course of Raku / Advanced / More about built-in types

Strings

In the Essentials part you learned how to build strings — concatenation, interpolation, and the length of a string. Strings also carry a rich set of methods. This section collects the most useful ones. (Searching with regular expressions is a separate, larger topic, covered in its own part later.)

Three methods change the letter case of a string:

say 'raku'.uc; # RAKU  — upper case
say 'RAKU'.lc; # raku  — lower case
say 'raku'.tc; # Raku  — title case (first letter capitalised)

The flip method reverses the characters of a string:

say 'Raku'.flip; # ukaR

And the x operator repeats a string a given number of times:

say 'ab' x 3; # ababab

The following topics show how to search inside strings and how to split them into parts and join them back together.

Topics in this section

Practice

Complete the 1 quiz that covers the contents of this section.

Exercises

This section contains 3 exercises. Examine all the topics of this section before doing the coding practice.

  1. Reverse and shout
  2. Acronym
  3. The domain part

Course navigation

Solution: A native array   |   Searching in strings