str_escape: Escape regular expression metacharacters

View source: R/escape.R

str_escapeR Documentation

Escape regular expression metacharacters

Description

This function escapes metacharacter, the characters that have special meaning to the regular expression engine. In most cases you are better off using fixed() since it is faster, but str_escape() is useful if you are composing user provided strings into a pattern.

Usage

str_escape(string)

Arguments

string

Input vector. Either a character vector, or something coercible to one.

Value

A character vector the same length as string.

Examples

str_detect(c("a", "."), ".")
str_detect(c("a", "."), str_escape("."))

stringr documentation built on Nov. 15, 2023, 1:08 a.m.