How to split a string into N substrings in a slice by separator include the separator in Go

1 Answer

0 votes
package main
  
import (
    "fmt"
    "strings"
)
  
func main() {
    s := strings.SplitAfterN("a,b,c,d,e", ",", 3)
     
    fmt.Printf("%q", s)
}
  
  
  
/*
run:
   
["a," "b," "c,d,e"]
   
*/

 



answered Aug 20, 2020 by avibootz

Related questions

1 answer 199 views
2 answers 237 views
1 answer 143 views
3 answers 305 views
305 views asked May 25, 2020 by avibootz
...