Learn R Programming

rebus (version 0.0-4)

as.regex: Convert or test for regex objects

Description

as.regex gives objects the class "regex". is.regex tests for objects of class "regex".

Usage

as.regex(x)

is.regex(x)

as.perl_regex(x)

is.perl_regex(x)

Arguments

x
An object to test or convert.

Value

  • as.regex returns the inputs object, with class c("regex", "character"). is.regex returns TRUE when the input inherits from class "regex" and FALSE otherwise. Similarly as.perl_regex gives the input object a class of c("perl_regex", "regex", "character"). For compatibility with the stringr package it also sets the attribute perl = TRUE.

Examples

Run this code
x <- as.regex("month.abb")
is.regex(x)
as.perl_regex("month.abb")
is.perl_regex(lookahead("a"))

Run the code above in your browser using DataLab