So what I am trying to achieve:
I have an input string that looks like this:
let inputString = "1*1 (10, 10) (5, 5)"
Note the space after the first digit within the brackets.
To separate this input, I am using:
inputString.components(separatedBy: " ")
Which returns the following array:
0: 1*1
1 "(10,"
2 "10)"
3 "(5,"
4: "5)"
Where as the result I want is:
0: "1*1"
1: "(10, 10)"
2: "(5, 5)"
The issue is that the space within the coordinate is causing the string to separate again, when I don't want it to.
I have also tried to separate them using:
inputString.replacingOccurrences(of: " ", with: "").components(separatedBy: CharacterSet.init(charactersIn: "\"([{)")).filter({ $0 != "" })
But this removes the "(" and ")" from the strings, which I need to keep.
Any suggestions would be welcome. Thanks