-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Documentation for counting functions
- Loading branch information
Showing
8 changed files
with
61 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#' @include escape.R | ||
#' @include utils.R | ||
NULL | ||
|
||
# TODO: Improve documentation, put +, * here as well | ||
#' Counts | ||
#' | ||
#' Functions to restrict a regex to a specific number | ||
#' @param x A regex pattern. | ||
#' @param n An integer number | ||
#' @param low An integer number for the lower limit. | ||
#' @param high An integer number for the upper limit. | ||
#' @aliases n | ||
#' @family rex | ||
#' @export | ||
n_times <- function(x, n) { | ||
p("(?:", p(escape(x)), "){", n, "}") | ||
} | ||
|
||
#' @export | ||
n <- n_times | ||
|
||
#' @export | ||
#' @describeIn n_times \code{x} must occur between \code{low} and \code{high} times. | ||
between <- function(x, low, high) { | ||
p("(?:", p(escape(x)), "){", low, ",", high, "}") | ||
} | ||
|
||
#' @export | ||
#' @describeIn n_times \code{x} must occur at least \code{n} times. | ||
at_least <- function(x, n) { | ||
between(x, n, '') | ||
} | ||
|
||
#' @export | ||
#' @describeIn n_times \code{x} must occur at most \code{n} times. | ||
at_most <- function(x, n) { | ||
between(x, '', n) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters