str_split_ws_quoted: Split string on whitespace leaving quoted regions intact

Description Usage Arguments Details Value Author(s) Examples

View source: R/str_split_ws_quoted.R

Description

Splits a string on whitespace while ignoring whitespace inside quotes

Usage

1
str_split_ws_quoted(x, quotes = c("'", "\""))

Arguments

x

character or string; (required)

quotes

character or string; character interpreted as quotes. The default is: ' single-quote and double-quote

Details

str_split_ws_quoted splits strings into a vector elements delineated by whitespace and ignoring whitespace enclosed in quotes. It also removes those quotes from strings.

str_split_ws_quoted uses not (yet?) allow for different opening and closing characters.

Value

character vector

Author(s)

Decision Patterns from the base.tools packages; used with permission.

Examples

1
2
3
4
5
6
7
  character(0) %>% str_split_ws_quoted()  # character(0)
  "" %>% str_split_ws_quoted()            # "" - no splitting
  "foo" %>% str_split_ws_quoted()         # "foo"
  "foo bar" %>% str_split_ws_quoted       # "foo" "bar"
  "'foo' bar" %>% str_split_ws_quoted     # "foo" "bar"
  "'foo' \"bar\"" %>% str_split_ws_quoted # "foo" "bar"
  "'foo bar" %>% str_split_ws_quoted      #

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