Currently, I have the following code:
cmd := "echo \"Hello world\"!\x00"
re := regexp.MustCompile(`[^\s"']+|"([^"]*)"|'([^']*)`)
args := re.FindAllString(cmd, -1)
fmt.Println("%v", args)
This yields the array %v [echo "Hello world" !]
, but I want the output to be %v [echo "Hello world"!]
(basically, quotes should contain everything inside of them as one item in the array, but the terminating quote should not signal the immediate start of the next item in the array).
How would I go about doing this?