Lessons

lesson 05 / 15

String manipulation

Kongue has a small set of methods for manipulating strings and lists. Common methods include:

  • split(delimiter) turns a string into a list.
  • join(delimiter) turns a list into a string.
  • cut(start, end) selects part of a string.
  • replace(old, new) replaces text.
  • lower(), upper(), and strip() change or clean a string.

Methods can be chained inside ${...}.

kongue
version: "2.78.1"

main {
    print "major: ${version.split(".")[0]}"
    print "short: ${version.cut(0, 4)}"
    print "underscored: ${version.replace(".", "_")}"
}