Highlight text within an R object which matches a given regex. This only works in a terminal which supports ANSI colour codes.
There are slightly different versions of the highlighting function depending upon which text version of the object you'd like to match against:
hl_grep(
x,
pattern,
coerce = "default",
opts = hl_opts(),
fill = NULL,
text = NULL,
...,
perl = TRUE
)
character string
regular expression string. Note: don't get too fancy here
How should non-character arguments be coerced to character strings?
- the given object x
must already be a character string
- performs the matching after first calling
as.character(x)
- performs the matching against the default
print(x)
output
- performs the matching after first calling
deparse1(x)
- performs the matching on the output of calling
str(x)
create options list
solid colour for background. If NULL
(the default),
then the default colour will be selected
text colour. If NULL
(the default), then a colour
will be seleted which contrasts with the fill
colour.
extra args passed to gsub
logical. use perl style regex. default: TRUE
hl_grep(mode, 'switch')
#> function (x)
#> {
#> if (is.expression(x))
#> return("expression")
#> if (is.call(x))
#> return(switch(deparse(x[[1L]])[1L], `(` = "(", "call"))
#> if (is.name(x))
#> "name"
#> else switch(tx <- typeof(x), double = , integer = "numeric",
#> closure = , builtin = , special = "function", tx)
#> }
#> <bytecode: 0x12b102948>
#> <environment: namespace:base>