I'm trying to search a String
for regex
using the following snippet (it's in an extension for String
):
var range = self.startIndex..<self.endIndex
while range.lowerBound < range.upperBound {
if let match = self.range(of: regex, options: .regularExpression, range: range, locale: nil) {
print(match)
range = ????? <============ this line, how do I update the range?
}
}
It will correctly find the first occurance, but then I don't know how to change the range to the position of the match to search the remainder of the string.