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.