assertive.strings (version 0.0-3)

create_regex: Create a regex from components.

Description

Creates a regex from regex components.

Usage

create_regex(..., l = list(), sep = "[- ]?")

Arguments

...
Character vectors of regex components.
l
A list of character vectors for alternate specification.
sep
Regex for separating components of complete regex. Defaults to "an optional space or hyphen".

Value

A string containing a regex. Each element in the vectors are pasted together, separated by the sep value. Those character vectors are then preceded by "^" (regex for 'start of string'() and followed by "$" (regex for end of string). Finally, the regexes are collapsed with "|" (regex for 'or').

Examples

Run this code
## Not run: 
# cas_number_components <- c(
#   "[[:digit:]]{1,7}", "[[:digit:]]{2}", "[[:digit:]]"
# )
# cas_number_rx <- create_regex(rx_components, sep = "-")
# ## End(Not run)

Run the code above in your browser using DataLab