* Durga Someswararao G <durgasomeswararao...@gmail.com> [190827 14:07]: > Hi, > > Can anyone help me in this case. > > I was reading byte data(array of bytes) from another process and converted > that data to string. Now I am trying to replace escape sequences \n with > strings.Replace function but golang not detecting it. > > Even I tried with bytes.Replace function but no use. > > Also observed even strings.Contains function also not detecting \n. > > Eg: > > strings.Replace("String1\nString2", "\n", "golang",-1 )
This playground link does what I think you are trying to do, based on your example: https://play.golang.org/p/VqNgO-P10oi package main import ( "fmt" "strings" ) func main() { var s = "Hello,\nplayground" fmt.Println(s) s = strings.Replace(s, "\n", " *** ", -1) fmt.Println(s) } If you use the playground to share a simple example of how you are currently using this and what you want the result to be, we will be able to help you better. ...Marvin -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/20190827182543.f5rlnnbbmzgciqmt%40basil.wdw.