Extracting quoted part from string : <p>I am trying following code to extract quoted part from a string: </p>

<pre><code>package main
import ("fmt")
func main(){
    var oristr = "This is a \"test string\" for testing only"
    var quotedstr = ""
    var newstr = ""
    var instring = false
    fmt.Println(oristr)
    for i,c := range oristr {
        fmt.Printf("Char number: %d; char: %c\n", i, c);
        if c = `"` {
            if instring
            {instring=false}
            else {instring=true}}
        if instring
        {quotedstr += c}
        else {newstr += c}
    }
    fmt.Printf("Newstr: %s; quotedstr = %s", newstr, quotedstr )
}
</code></pre>

<p>However, I am getting following error: </p>

<pre><code># command-line-arguments
./getstring.go:11:14: syntax error: c = `"` used as value
./getstring.go:12:15: syntax error: unexpected newline, expecting { after if clause
./getstring.go:14:4: syntax error: unexpected else, expecting }
./getstring.go:15:3: syntax error: non-declaration statement outside function body
</code></pre>

<p>Why I am getting this error and how can this be corrected? </p>

<p>Also, is this approach all right or some other approach may be better?</p>
