regexr (version 1.1.0)

as.regexr: Generic Method to Coerce to regexr

Description

Coerce an object to regexr class.

Usage

as.regexr(x, names = TRUE, comments = TRUE, names.above = FALSE, comments.below = FALSE, ...)

Arguments

x
An object to coerce to a regexr object.
names
logical. Should names be included in the construct script?
comments
logical. Should comments be included in the construct script?
names.above
logical. Should ames be included above the regex in the construct script? If FALSE names are placed in front of the sub-expressions.
comments.below
logical. Should comments be included below the sub-expressions in the construct script? If FALSE comments are placed behind the sub-expressions.
...
Other arguments passed to as.regexr methods.

Value

Returns a dual regexr and reverse_construct object.

Examples

Run this code
## Not run: 
# ## NOTE: These examples will likely fail unless
# ## http://rick.measham.id.au/paste/explain becomes available again.
# library("qdapRegex")
# (myregex <- grab("@rm_time2"))
# out <- as.regexr(myregex)
# 
# out
# summary(out)
# comments(out)
# subs(out)
# test(out)
# get_construct(out)
# 
# ## On Windows copy to clipboard
# get_construct(out, file="clipboard")
# 
# ## No names & comments behind sub-expressions
# myregex2 <- "(\\s*[a-z]+)([^)]+\\))"
# get_construct(as.regexr(myregex2, names=FALSE))
# get_construct(as.regexr(myregex2, names=FALSE, names.above = TRUE,
#     comments.below = TRUE))
# ## End(Not run)

Run the code above in your browser using DataCamp Workspace