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 132 views
1 answer 141 views
1 answer 142 views
2 answers 162 views
1 answer 124 views
1 answer 123 views
1 answer 2,226 views
...