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

        return nil
      }
      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)
      if let match = regex.firstMatch(in: string, options: options, range: range) {

      guard let regex = regex else {
        return (string, 0)
      }
      let range = NSRange(location: 0, length: string.utf16.count)
      let mutable = NSMutableString(string: string)
      let maxCount = count == 0 ? Int.max : (count > 0 ? count : 0)
      var n = 0
