How to replace comma (,) with semicolon (;) in a string with Go

1 Answer

0 votes
package main

import (
    "fmt"
    "strings"
)

func main() {
    str := "java,c,c++,c#,rust,go"

    // Replace commas with semicolons
    str = strings.ReplaceAll(str, ",", ";")

    fmt.Println(str)
}




/*
run:

java;c;c++;c#;rust;go

*/

 



answered Dec 3, 2024 by avibootz

Related questions

1 answer 134 views
1 answer 142 views
1 answer 145 views
2 answers 165 views
1 answer 128 views
1 answer 125 views
1 answer 2,229 views
...