import Foundation
let pattern = #"(?:.*|)NY TORRENT: [a-zA-Z&]+ \w+ (.*-[a-zA-Z]+).*"#
let regex = try! NSRegularExpression(pattern: pattern, options: .anchorsMatchLines)
let testString = #"""
NY TORRENT: Dance Single Croatia_Squad_-_Touch_Me-(ETR236)-WEB-2014-XDS 41.62MB (http://tunetraxx.org/?p=torrents&pid=10&action=details&tid=1972)
NY TORRENT: Dance Single Croatia_Squad_-_Touch_Me-(ETR236)-WEB-2014-XDS 41.62MB (http://tunetraxx.org/?p=torrents&pid=10&action=details&tid=1972)
NY TORRENT: R&B Album David_Guetta-Listen-2CD-2014-VOiCE 116.67MB (http://tunetraxx.org/?p=torrents&pid=10&action=details&tid=1973)
NY TORRENT: Club Single DJ_EBO_-_Triple_Jump_98-Vinyl-1998-iDC 33.98MB (http://tunetraxx.org/?p=torrents&pid=10&action=details&tid=1974)
(22:15:27) (@TTBot) NY TORRENT: Dance Single Audio_Hedz_and_Bones_-_Boom_Bang-(OMP_004)-WEB-2013-NRG 14.58MB (http://tunetraxx.org/?p=torrents&pid=10&action=details&tid=1749)
(22:15:27) (@TTBot) NY TORRENT: Dance Single Bounce_Enforcerz_-_Good_Dawn-(RRBEG)-WEB-2014-NRG 16.12MB (http://tunetraxx.org/?p=torrents&pid=10&action=details&tid=1750)
"""#
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