import Foundation
let pattern = #".*(?<=")(?!US|CN)(?=\w{2}"|").*"#
let regex = try! NSRegularExpression(pattern: pattern, options: .anchorsMatchLines)
let testString = #"""
[
[707860,"UA","Hurzuf"],
[519188,"RU","Novinki"],
[1283378,"NP","Gorkhā"],
[1270260,"IN","State of Haryāna"],
[708546,"UA","Holubynka"],
[1283710,"NP","Bāgmatī Zone"],
[529334,"RU","Mar’ina Roshcha"],
[529334,"US","Mar’ina Roshcha"],
[6255149,"","North America"],
[1269750,"IN","Republic of India"],
[1283240,"NP","Kathmandu"],
[703363,"UA","Laspi"],
[3632308,"VE","Merida"],
[473537,"CN","Vinogradovo"],
[473537,"RU","Vinogradovo"],
[384848,"IQ","Qarah Gawl al ‘Ulyā"],
[569143,"RU","Cherkizovo"],
[713514,"UA","Alupka"],
[2878044,"DE","Lichtenrade"],
]
"""#
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