import Foundation
let pattern = #"<\/?\s*span\s*>|<\s*br\s*\/?\s*>"#
let regex = try! NSRegularExpression(pattern: pattern, options: .anchorsMatchLines)
let testString = #"<p><span>Discover a new tough case for your iPhone 5 with Active Urban</span><span>™</span><span> Case from Cat phones.<br/>Made to survive the challenges of everyday life, this protective case will shield your device whether you\'ve chucked it in your bag, dropped it on the floor or left it in clumsy hands.<br>No matter the situation, the Active Urban</span><span>™</span><span> Case will live up to the challenge.</span></p>"#
let stringRange = NSRange(location: 0, length: testString.utf16.count)
let substitutionString = #""#
let result = regex.stringByReplacingMatches(in: testString, range: stringRange, withTemplate: substitutionString)
print(result)
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Swift 5.2, please visit: https://developer.apple.com/documentation/foundation/nsregularexpression