I need to read some formatted data from a string and store it in two variables. The string has this format:
data = "(1234),(-567)"
The numbers are of varying lengths and signs. I feel like this should be simple. It would be easy in C:
scanf(data, "(%d),(%d)", num1, num2)
But in Swift, I'm pulling my hair out trying to find an easy way to do this. As suggested in other answers, I've tried:
data.components(separatedBy: CharacterSet.decimalDigits.inverted)
However this overlooks minus signs. Any help is much appreciated!