as_path_to_pattern {ambiorix} | R Documentation |
Path to pattern
Description
Identify a function as a path to pattern function; a function that accepts a path and returns a matching pattern.
Usage
as_path_to_pattern(path)
Arguments
path |
A function that accepts a character vector of length 1 and returns another character vector of length 1. |
Value
Object of class "pathToPattern".
Examples
fn <- function(path) {
pattern <- gsub(":([^/]+)", "(\\\\w+)", path)
paste0("^", pattern, "$")
}
path_to_pattern <- as_path_to_pattern(fn)
path <- "/dashboard/profile/:user_id"
pattern <- path_to_pattern(path) # "^/dashboard/profile/(\w+)$"
[Package ambiorix version 2.2.0 Index]