R/jambio-design.R
escapeWhitespaceRegexp.Rd
Escape whitespace in regular expression patterns
escapeWhitespaceRegexp(x, whitespace = "_ ", maxN = 20, ...)
x | character vector containing a regular expression pattern, or a character value that should be converted to a regular expression pattern. |
---|---|
whitespace | character vector |
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. |
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.
Other jam string functions:
sortSamples()
,
strsplitOrdered()
#> [1] "one[_ ]+two[_ ]+three" "one[ ]two[_ ]+three" #> [3] "one[ 12][_ ]+two[_ ]+three"# side-by-side summary of input and output data.frame(input=paste0('"', x, '"'), output=paste0('"', escapeWhitespaceRegexp(x), '"'))#> input output #> 1 "one two three" "one[_ ]+two[_ ]+three" #> 2 "one[ ]two three" "one[ ]two[_ ]+three" #> 3 "one[ 12] two three" "one[ 12][_ ]+two[_ ]+three"