Golang String Manipulation

GoGoBeginner
Practice Now

This tutorial is from open-source community. Access the source code

Introduction

The strings package in Golang provides many useful string-related functions. This challenge aims to test your understanding of some of these functions.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL go(("`Go`")) -.-> go/DataTypesandStructuresGroup(["`Data Types and Structures`"]) go/DataTypesandStructuresGroup -.-> go/strings("`Strings`") subgraph Lab Skills go/strings -.-> lab-15432{{"`Golang String Manipulation`"}} end

String Functions

Complete the code below to print the output of various string functions provided by the strings package.

Requirements

  • Use the strings package to complete the challenge.
  • Use the fmt.Println function to print the output.
  • Do not modify the function name or parameters.

Example

$ go run string-functions.go
Contains: true
Count: 2
HasPrefix: true
HasSuffix: true
Index: 1
Join: a-b
Repeat: aaaaa
Replace: f00
Replace: f0o
Split: [a b c d e]
ToLower: test
ToUpper: TEST

Summary

This challenge tests your understanding of the strings package in Golang. You should be able to use the various functions provided by the package to manipulate strings.

Other Go Tutorials you may like