I'm looking for a way to get the ranges from a regex match. I have a string
I'm looking for @{1 | Tom Lofe} and @{2 | Cristal Dawn}
From this string, I need to get the ranges of these matches using the following regex
"@\\{(\\d+) ?\\| ?(\\w+ *?\\w*?)\\}"
What is the best way to do this? So far I've only been able to get the matches but not the ranges. Apparently, the standard Swift function range(of: <#T##StringProtocol#>, options: <#T##String.CompareOptions#>, range: <#T##Range<String.Index>?#>, locale: <#T##Locale?#>)
should be able to do this, but I don't know how to use it, and can't seem to find a good example.
I've also tried this question's answer get all ranges of a substring in a string in swift but again am unable to get it to work.