You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When given an invalid range, the internal prepareRegularExpression function returns NULL, which results in a silent failure with zero matches. I'm not sure if this behavior is considered a bug.
Note that your ss.count example gives the number of characters (extended grapheme clusters), but NSRegularExpression needs an NSRange of UTF-16 code units.
Environment
Raspian Linux Swift version 5.1.5-v0.1
Additional Detail from JIRA
md5: 957478105529dab8d74d9fcb73634dae
Issue Description:
Given a regular expression like:
let testExp = try! NSRegularExpression(pattern: "(^| /) .", options: [])
The code:
let ss = "/Pairs Series/._Chair15.jpg"
let tRange = NSMakeRange(0, ss.count + 2)
let matches = testExp.numberOfMatches(in: ss, options: [], range: tRange)
fails on the Mac with: '...Range or index out of bounds'
but works under Raspian returning 0 matches.
Under Raspian, it should either fail or return 1 match.
The text was updated successfully, but these errors were encountered: