import Foundation
let pattern = #"=+|GOLIATH"#
let regex = try! NSRegularExpression(pattern: pattern)
let testString = ##"""
=====================================================================================
GOLIATH
=====================================================================================
*** GOLIATH BACKUP CHECK *** GOLIATH BACKUP CHECK *** GOLIATH BACKUP CHECK ***
====]] GOLIATH Backup Check Results [[====
--] Remote Reachability Test
Pings were NOT successful to 172.16.158.1 from remote router uscmcraudfl04r.
USCMCRAUDFL04R#ping 172.16.158.1 source FastEthernet0
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.158.1, timeout is 2 seconds:
Packet sent with a source address of 172.16.112.1
.....
Success rate is 0 percent
--] Backup Device Test
GOLIATH did not detect any backup devices connected to the router.
--] Back-to-Back Test
No SMARTS Back-to-Back connections detected.
GOLIATH did not detect any iBGP connections for this device.
--] ISDN Test
No ISDN interfaces detected on router or B2B routers.
=====================================================================================
"""##
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