import Foundation
let pattern = #"FA-I1-I2-TR-I1-I2-FA.*(*SKIP)(*F)|(?:I\d-?)*I3(?:-?I\d)*"#
let regex = try! NSRegularExpression(pattern: pattern, options: .anchorsMatchLines)
let testString = #"1-FA-I2-I2-I2-EX-I2-I3-FA-I1-I2-TR-I1-I2-FA-I3-I1-FA-FA-NR-I3-I2-TR-I1-I2-I1-I2-FA-I2-I1-I3-FA-QU-I1-I2-I2-I2-NR-I2-I2-NR-I1-I2-I1-NR-I3-QU-I2-I3-QU-NR-I2-I1-NR-QU-QU-I2-I1-EX"#
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