Hi
let regex1 = #"^[0-9]{4}-[0-9][0-9]?-[0-9][0-9]?$"#
let range1 = input.range(of: regex1, options: .regularExpression)
let string1:String
if range1 != nil {
string1 = input + "T00:00:00.000"
}else{
let range = NSRange(location: 0, length: input.utf8.count)
let pattern =
"^([0-9]{4}-[0-9][0-9]-[0-9][0-9]).([0-2][0-9]:[0-5][0-9]:[0-6][0-9]\\.[0-9][0-9][0-9])$"
let regEx = try! NSRegularExpression(
pattern: pattern,
options: []
)
if let match = regEx.firstMatch(in: input, options: [], range: range){
let d1 = Range(match.range(at: 1), in: input)
let d2 = Range(match.range(at: 2), in: input)
if d1 != nil && d2 != nil {
string1 = input[d1!] + "T" + input[d2!]
}else{
string1 = ""
}
}
}
Called that < 1_000_000 times and used up 5G of memory