import Foundation
// WARNING: You included a flag that Swift doesn't support: u
// When this flag is set, it makes the pattern and subject strings to be treated as unicode.
// Swift already treats the pattern and subject strings as unicode by default, so including this flag is redundant.
let pattern = #"(?:в|от)?\s*(?:\d{1,2})?\s*\b(?:янв|фев|мар|апр|ма|июн|июл|авг|сен|окт|ноя|дек)\w*\b\s*\d{4}\s*(?:г\.|года?)|(?:от|в)?\s*\d{2}\.\d{2}.\d{4}(?:г\.?)?"#
let regex = try! NSRegularExpression(pattern: pattern, options: .anchorsMatchLines)
let testString = #"Текущая строка для проверки: Оплата за выполненные работы в октябре 2019 года дог.N07/18 от 30.03.2018г. по негарантированному заказу, сч.N00290005604 от 08.11.2019, вт.ч. НДС (20%) от 12 сентября 2020 года 381,36"#
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