         do {
             let exp = try NSRegularExpression(pattern: regex, options: options)
             let nsString = self as NSString
-            let results = exp.matches(in: self, options: [], range: NSMakeRange(0, self.length))
+            let results = exp.matches(in: self, options: [], range: NSMakeRange(0, self.count))
             return results.map{nsString.substring(with: $0.range)}
         } catch {
             return []

    public func isMatch(_ regex: String, options: NSRegularExpression.Options) -> Bool {
        do {
            let exp = try NSRegularExpression(pattern: regex, options: options)
            return exp.numberOfMatches(in: self, options: [], range: NSMakeRange(0, self.length)) > 0
        } catch {
            return false
        }

    public func trim() -> String {
        return self.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
    }
    
}
