rx_whitespace: Match a whitespace character.

View source: R/special_characters.R

rx_whitespaceR Documentation

Match a whitespace character.

Description

Match a whitespace character.

Usage

rx_whitespace(.data = NULL, inverse = FALSE)

Arguments

.data

Expression to append, typically pulled from the pipe %>%

inverse

Invert match behavior, defaults to FALSE (match whitespace). Use TRUE to not match whitespace.

Details

Match a whitespace character (one of space, tab, carriage return, new line, vertical tab and form feed).

  1. space: https://codepoints.net/U+0020

  2. tab: https://codepoints.net/U+0009

  3. carriage return: https://codepoints.net/U+000D

  4. new line: https://codepoints.net/U+000

  5. vertical tab: https://codepoints.net/U+000B

  6. form feed: https://codepoints.net/U+000C

Examples

# match whitespace, default
rx_whitespace()

# dont match whitespace
rx_whitespace(inverse = TRUE)

# create an expression
x <- rx_whitespace()

# create input
string <- "1 apple"

# extract match
regmatches(string, regexpr(x, string))

# extract no whitespace by inverting behavior
y <- rx_whitespace(inverse = TRUE)
regmatches(string, gregexpr(y, string))

VerbalExpressions/RVerbalExpressions documentation built on March 27, 2024, 8:20 a.m.