Carlosra1375
Carlosra1375

Reputation: 105

How Can I split a string by the character "

enter image description here

That is what I have, and I tried to split like: (Using Golang)

idPost = strings.Split(idPost,'"')

but the compiler said IncompatibleAssign using '"'.

Upvotes: 6

Views: 13178

Answers (2)

Timofey Belanenko
Timofey Belanenko

Reputation: 171

Use a back quote instead of an apostrophe, example:

idPost = strings.Split(idPost,`"`)

Upvotes: 12

Chris Schaller
Chris Schaller

Reputation: 16554

you need to escape it, so your question is how to escape characters in go.

Escapes and multiline strings

You will find this is similar across many languages:

dPost = strings.Split(idPost,"\"")

Upvotes: 1

Related Questions