hl_grep {emphatic}R Documentation

Colour highlighting a regular expression search

Description

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:

Usage

hl_grep(
  x,
  pattern,
  coerce = "default",
  opts = hl_opts(),
  fill = NULL,
  text = NULL,
  ...,
  perl = TRUE
)

Arguments

x

character string

pattern

regular expression string. Note: don't get too fancy here

coerce

How should non-character arguments be coerced to character strings?

default

- the given object x must already be a character string

character

- performs the matching after first calling as.character(x)

print

- performs the matching against the default print(x) output

deparse

- performs the matching after first calling deparse1(x)

str

- performs the matching on the output of calling str(x)

opts

create options list

fill

solid colour for background. If NULL (the default), then the default colour will be selected

text

text colour. If NULL (the default), then a colour will be seleted which contrasts with the fill colour.

...

extra args passed to gsub

perl

logical. use perl style regex. default: TRUE

Value

An emphatic object suitable to output to console (for example)

Examples

hl_grep(mode, 'switch')

[Package emphatic version 0.1.8 Index]