Be careful with above solution: NSMakeRange(0, self.count) is not correct, because self is a String (=UTF8) and not an NSString (=UTF16). So the self.count is not necessarily the same as nsString.length (as used in other solutions). You can replace the range calculation with NSRange(self.startIndex..., in: self) – pd95 Jun 29 at 22:27
Fixed
String.count
shouldn't be used to createNSRange
. See the comment on https://stackoverflow.com/questions/27880650/swift-extract-regex-matches#comment110787889_54900097Thanks for the great repo!