import Foundation
let pattern = #"[.?!;\n"]"#
let regex = try! NSRegularExpression(pattern: pattern)
let testString = #"""
ì¡°ì„ ì¤‘ì•™í†µì‹ ì€ 7ì¼ ê¹€ì •ì¼ êµë°©ìœ„ì›ìž¥ì´ 마무리 ë‹¨ê³„ì¸ ë¡€ì„±ê°• ì²ë…„2í˜¸ë°œì „ì†Œ ê±´ì„¤í˜„ìž¥ì„ í˜„ì§€ì§€ë„ í–ˆë‹¤ê³ ì „í–ˆë‹¤. ê¹€ 위ì›ìž¥ì€ ?공사 ìƒí™©ì„ ë³´ê³ ë°›ê³ í˜„ìž¥ì„ ë‘˜ëŸ¬ë³¸ ë’¤
\"례성강 ì²ë…„2í˜¸ë°œì „ì†ŒëŠ” ìš°ë¦¬ì˜ í›„ëŒ€ë“¤ì—게 ë¬¼ë ¤ì¤„ 나ë¼ì˜ 귀중한 재부ì´ë©°, 먼 í›—ë‚ ì— ê°€ì„œë„ ì†ìƒ‰ 없게 ê±´ì„¤ì˜ ì§ˆì„ ìµœìƒì˜ 수준ì—서 보장해야 한다\"면서 \"ëª¨ë“ ì „ì„ ì—서 ëŒ€ì§„ê³µì „ì„ ê³¼ê°ížˆ ë²Œë ¤ ë¯¼ì¡±ì‚¬ì— ì¼ì°ì´ ì—†ì—ˆë˜ ì„¸ê¸°ì ì¸ ìœ„ì—…ì„ ì´ë£©í•˜ìž\"ê³ ë§í–ˆë‹¤ê³ í†µì‹ ì€ ë³´ë„했다.
"""#
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