import Foundation
let pattern = #"<[^>]*?href\s*=\s*"[^>]*?blogspot\.com[^>]*>(<img[^>]*?\/>)<\/[^>]*>"#
let regex = try! NSRegularExpression(pattern: pattern, options: [.anchorsMatchLines, .caseInsensitive])
let testString = #"""
<a style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;" href="http://3.bp.blogspot.com/xxxxxxx.JPG"><img src="xxxxxxxxxxxxxx" alt="" width="200" height="150" border="0" /></a>
"""#
let stringRange = NSRange(location: 0, length: testString.utf16.count)
let substitutionString = #"$1"#
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