import Foundation
let pattern = #"(select\s+|([^,]+as)|from.+)"#
let regex = try! NSRegularExpression(pattern: pattern, options: [.anchorsMatchLines, .caseInsensitive])
let testString = #"""
SELECT id, id_alarm, ne_name, extract(epoch from create_alarm_dt) as create_alarm_dt, extract(epoch from create_date) as create_date, extract(epoch from modify_date) as modify_date, create_user, modify_user, description FROM ecus.prog_ack_comments WHERE create_user='avpozov'
id,id_alarm, ne_name, extract(epoch from create_alarm_dt) as create_alarm_dt, extract(epoch from create_date) as create_date, extract(epoch from modify_date) as modify_date, create_user, modify_user, description
"""#
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