Skip to content

Commit

Permalink
Add description on string examples
Browse files Browse the repository at this point in the history
  • Loading branch information
naeemaei committed Oct 7, 2023
1 parent e8b8bac commit 06c67e4
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions 04-Variables/04-Functions/funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
func main() {
myString := "this is golang tutorial go go"

fmt.Println(strings.Contains(myString, "go1"))
fmt.Println(strings.ContainsAny(myString, "go1"))
fmt.Println(strings.Count(myString, "go"))
fmt.Println("EqualFold", strings.Contains(myString, "go1"))
fmt.Println("EqualFold", strings.ContainsAny(myString, "go1"))
fmt.Println("EqualFold", strings.Count(myString, "go"))
fmt.Println(strings.Cut(myString, "go1"))

myStringArray := strings.Split(myString, " ")
Expand All @@ -23,39 +23,39 @@ func main() {

myStringArray2 := strings.Join(myStringArray, ",")

println(myStringArray2)
println("Join", myStringArray2)

println(strings.Repeat("iran ", 10))
println("Repeat", strings.Repeat("iran ", 10))

println(strings.Replace(myString, "golang", "go", 3))
println(strings.ReplaceAll(myString, "go", "golang"))
println("Replace", strings.Replace(myString, "golang", "go", 3))
println("ReplaceAll", strings.ReplaceAll(myString, "go", "golang"))

println(strings.Compare("golang", "golang"))
println(strings.Compare("Golang", "golang"))
println(strings.Compare("Golang", "GOLANG"))
println("Compare", strings.Compare("golang", "golang"))
println("Compare", strings.Compare("Golang", "golang"))
println("Compare", strings.Compare("Golang", "GOLANG"))

println(strings.EqualFold("Golang", "GOLANG"))
println(strings.EqualFold("Golang", "golang"))
println("EqualFold", strings.EqualFold("Golang", "GOLANG"))
println("EqualFold", strings.EqualFold("Golang", "golang"))


println(strings.HasPrefix("Iran", "Ir"))
println(strings.HasPrefix("Iran", "IR"))
println("HasPrefix", strings.HasPrefix("Iran", "Ir"))
println("HasPrefix", strings.HasPrefix("Iran", "IR"))

println(strings.HasSuffix("Iran", "an"))
println(strings.HasSuffix("Iran", "n"))
println("HasSuffix", strings.HasSuffix("Iran", "an"))
println("HasSuffix", strings.HasSuffix("Iran", "n"))

println(strings.Index("Iran", "an"))
println(strings.Index("Iran", "r"))
println("Index an", strings.Index("Iran", "an"))
println("Index r", strings.Index("Iran", "r"))


println(strings.ToLower("IrAn"))
println(strings.ToUpper("IrAn"))
println(strings.Title("Iran is a country"))
println("ToLower", strings.ToLower("IrAn"))
println("ToUpper", strings.ToUpper("IrAn"))
println("Title", strings.Title("Iran is a country"))

println(strings.Trim(" Iran is a country ", " "))
println(strings.TrimLeft("!!Iran is a country!!", "!"))
println(strings.TrimRight("!!Iran is a country!!", "!"))
println(strings.Trim("!!Iran is a country!!", "!"))
println("Trim", strings.Trim(" Iran is a country ", " "))
println("TrimLeft", strings.TrimLeft("!!Iran is a country!!", "!"))
println("TrimRight", strings.TrimRight("!!Iran is a country!!", "!"))
println("Trim", strings.Trim("!!Iran is a country!!", "!"))



Expand Down

0 comments on commit 06c67e4

Please sign in to comment.