I'm trying to extract all words from a string which are between quotes.
Here's my current code:
func StrExtract(word string) []string {
r, _ := regexp.Compile(`".*"`)
result := r.FindAllString(word, -1)
RemoveDuplicates(&result)
return (result)
}
Test the code here
With an input like:
`Hi guys, this is a "test" and a "demo" ok?`
I get the output:
["test" and a "demo"]
But I'd like to get:
[test demo]
Please help me fix this, or suggest better alternatives.