Yesterday I asked this question about splitting a string in python. I've since decided to do this project in Go instead. I have the following:
input := "house-width + 3 - y ^ (5 * house length)"
s := regexp.MustCompile(" ([+-/*^]) ").Split(input, -1)
log.Println(s) // [house-width 3 y (5 house length)]
How do I include the operators in this output? e.g. I'd like the following output:
['house-width', '+', '3', '-', 'y', '^', '(5', '*', 'house length)']
EDIT: To clarify I am splitting on the space-separated operators and not just the operator. The operator must have a space on both ends to differentiate it from a dash/hyphen. Please refer to my original python question I linked to for clarification if needed.