Skip to content

Escape characters for a regex

Usage

escape(x)

# S3 method for regex
escape(x)

# S3 method for character_class
escape(x)

# S3 method for character
escape(x)

# S3 method for default
escape(x)

# S3 method for list
escape(x)

Arguments

x

Object to escape.

Methods (by class)

  • regex: Objects are simply passed through unchanged.

  • character_class: Objects are surrounded by braces.

  • character: Objects are properly escaped for regular expressions.

  • default: default escape coerces to character and escapes.

  • list: simply call escape on all elements of the list.