Post

Replies

Boosts

Views

Activity

NSRegularExpressions will get stuck when matching strings containing emoji with String.count.
Xcode 13.2.1 Swift 5 This problem occurs on iOS simulator and real device (both with iOS 15.2). It seems to occur only when dotMatchesLineSeparators is specified as an option. When the same code is implemented in Objective-C, the problem does not occur. This will not occur if the length of range is set to message.utf16.count. let message = "Hello 😂"; let regexp = try! NSRegularExpression(pattern: "((.*\n){15})", options: .dotMatchesLineSeparators) let res = regexp.rangeOfFirstMatch( in: message, options: [], range: NSRange(location: 0, length: message.count) ).location != NSNotFound print(res) Isn't it a bug in NSRegularExpression?
1
0
338
Feb ’22