-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from dmi3kno/master
Adding lazy mode, lookarounds, none_or_more, count and digits
- Loading branch information
Showing
30 changed files
with
420 additions
and
22 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
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,26 @@ | ||
#' Negative lookaround functions | ||
#' | ||
#' @description This function facilitates matching by providing negative assurances for surrounding symbols/groups of symbols. | ||
#' It allows for building expressions that are dependent on context of occurence. | ||
#' | ||
#' @param .data Expression to append, typically pulled from the pipe \code{ \%>\% } | ||
#' @param value Exact expression to match | ||
#' | ||
#' @examples | ||
#' # matches any number of digits, but not preceded by "USD" | ||
#' rx() %>% rx_avoid_prefix('USD') %>% rx_digit() %>% rx_one_or_more() | ||
#' | ||
#' #matches a digit, but not followed by " dollars" | ||
#' rx() %>% rx_digit() %>% rx_avoid_suffix(' dollars') | ||
#' | ||
#' @rdname rx_avoid | ||
#' @export | ||
rx_avoid_prefix <- function(.data = NULL, value) { | ||
paste0(.data, "(?<!", sanitize(value), ")") | ||
} | ||
|
||
#' @rdname rx_avoid | ||
#' @export | ||
rx_avoid_suffix <- function(.data = NULL, value) { | ||
paste0(.data, "(?!", sanitize(value), ")") | ||
} |
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,24 @@ | ||
#' Match the previous stuff exact number of times. | ||
#' | ||
#' @description This function simply adds a \code{{n}} to the end of the expression. | ||
#' | ||
#' @param .data Expression to append, typically pulled from the pipe \code{ \%>\% } | ||
#' @param n Number of times previous expression shall be repeated. Default is 1. | ||
#' | ||
#' @examples | ||
#' rx_count() | ||
#' | ||
#' # create an expression | ||
#' x <- rx_find(value = "a") %>% | ||
#' rx_count(3) | ||
#' | ||
#' # create input | ||
#' input <- "aaa" | ||
#' | ||
#' # extract match | ||
#' regmatches(input, regexpr(x, input)) | ||
#' | ||
#' @export | ||
rx_count <- function(.data = NULL, n = 1) { | ||
paste0(.data, "{", 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#' Positive lookaround functions | ||
#' | ||
#' @description This function facilitates matching by providing assurances for surrounding symbols/groups of symbols. | ||
#' It allows for building expressions that are dependent on context of occurence. | ||
#' | ||
#' @param .data Expression to append, typically pulled from the pipe \code{ \%>\% } | ||
#' @param value Exact expression to match | ||
#' | ||
#' @examples | ||
#' # this will match anything between square brackets | ||
#' rx() %>% | ||
#' rx_seek_prefix("[") %>% | ||
#' rx_anything("lazy") %>% | ||
#' rx_seek_suffix(']') | ||
#' | ||
#' @rdname rx_seek | ||
#' @export | ||
rx_seek_prefix <- function(.data = NULL, value) { | ||
paste0(.data, "(?<=", sanitize(value), ")") | ||
} | ||
|
||
#' @rdname rx_seek | ||
#' @export | ||
rx_seek_suffix <- function(.data = NULL, value) { | ||
paste0(.data, "(?=", sanitize(value), ")") | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.