func testFunc(attribString: AttributedString)->AttributedString {
// attribString is a markdown AttributedString for example = "Lorem ipsum dolor <test>first tag</test>sit Donec <test>second tag</test>"
if let range = attribString.range(of: "<test>(.*?)</test>", options: .regularExpression) {
attribString[range].foregroundColor = .red
}
}
the documentation says: range(of) - Finds and returns the range of the first occurrence of a given string within the string.
But how can I find the range of all occurrences in the string with regex so that I can assign it a color or other attribute?
Could a loop be a good idea?
for range in ranges {
attribString[range].foregroundColor = .red
}
Thanks for help