1#' Count the occurrences of a substring.
2#'
3#' Return the number of non-overlapping occurrences of substring \code{sub} in the range \code{start, end}.
4#'
5#' @param str A character vector.
6#' @param sub A character string.
7#' @param start An integer.
8#' @param end An integer.
9#'
10#' @return A numeric vector.
11#'
12#' @references \url{https://docs.python.org/3/library/stdtypes.html#str.count}
13#'
14#' @examples
15#' pystr_count("ababab", "aba")
16#' pystr_count("abcxyzabc123", "abc")
17#' pystr_count("a--b--c", "--", 4)
18#' pystr_count(c("one", "two", "three"), "e")
19#'
20#' @export
21pystr_count <- function(str, sub, start=1, end=max(nchar(str))) {
22  return(pystr_count_(str, sub, start - 1, end - 1))
23}
24