         return nil
       }
       let start = pos > 0 ?pos :0
-      let end = endpos ?? string.characters.count
+      let end = endpos ?? string.utf16.count
       let length = max(0, end - start)
       let range = NSRange(location: start, length: length)
       if let match = regex.firstMatchInString(string, options: options, range: range) {

        return []
      }
      let start = pos > 0 ?pos :0
      let end = endpos ?? string.characters.count
      let length = max(0, end - start)
      let range = NSRange(location: start, length: length)
      return regex.matchesInString(string, options: [], range: range).map { MatchObject(string: string, match: $0) }

        return []
      }
      var splitsLeft = maxsplit == 0 ? Int.max : (maxsplit < 0 ? 0 : maxsplit)
      let range = NSRange(location: 0, length: string.utf16.count)
      var results = [String?]()
      var start = string.startIndex
      var end = string.startIndex
