str_escape: Escape dot(.) in a string

Description Usage Arguments Details Examples

View source: R/str_escape.R

Description

Replaces . with \. in strings.

Usage

1
2
3
str_escape(string, x, escape = "\\")

str_escape_dot(string, x = ".", escape = "\\")

Arguments

string

string

x

string to be escaped, usually a single character.

Details

str_escape escapes all instances of x in a string by \. This is handy when working with regular expressions, file descriptors, etc. where certain characters have special meaning. By escaping, the character will match litereally instead of using their special meanings.

str_escape_dot wraps str_escape using x='.' and escape='\\'

Examples

1
2
3
4
5
  str_escape( "path/to/file", "/" )
  str_escape( "path/to/file", "/", "\\" )

  str_escape_dot("hello.world")   # "hello\\.world"
  str_escape_dot("foo.bar.baz")   # "foo\\.bar\\.baz"

decisionpatterns/stringr.tools documentation built on Nov. 4, 2019, 10:24 a.m.