escapeWhitespaceRegexp: Escape whitespace in regular expression patterns

escapeWhitespaceRegexpR Documentation

Escape whitespace in regular expression patterns

Description

Escape whitespace in regular expression patterns

Usage

escapeWhitespaceRegexp(x, whitespace = "_ ", maxN = 20, ...)

Arguments

x

character vector containing a regular expression pattern, or a character value that should be converted to a regular expression pattern.

whitespace

character vector length=1 containing whitespace characters, for example " _" will define space " " and underscore "_" both as whitespace characters.

maxN

integer value for maximum iterations of the substitution, unfortunately the regular expression logic only matches once per iteration per string.

...

additional arguments are ignored.

Details

This function is intended to test for unescaped whitespace characters in a regular expression pattern match string, and replace them with escaped whitespace characters, possibly expanding the allowed whitespace characters in the process.

See Also

Other jam string functions: sortSamples(), strsplitOrdered()

Examples

x <- c("one two three", "one[ ]two three", "one[ 12] two three");
escapeWhitespaceRegexp(x);
# side-by-side summary of input and output
data.frame(input=paste0('"', x, '"'),
   output=paste0('"', escapeWhitespaceRegexp(x), '"'))


jmw86069/splicejam documentation built on Nov. 4, 2024, 10:53 a.m.