import Foundation
let pattern = #"^\w{42} "#
let regex = try! NSRegularExpression(pattern: pattern, options: .anchorsMatchLines)
let testString = #"""
0x8DA1937198d1A51d735aa3E57423183888539E48 0x92b7b421992ef490f3b75898ec0e511f1a5c02422819d89719b20362b023ce4f
0x5D9D8F9F0E0E3D6B07C4Fa829Bf0550D5846E6e2 0x4a7657258f0bc1744c32bed405c0b53b5addcf210f8c15a8f69d168b0ccfc492g2
"""#
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