str_split: Split up a string into pieces

View source: R/str_split.R

str_splitR Documentation

Split up a string into pieces

Description

Dependency-free drop-in alternative for stringr::str_split().

Usage

str_split(string, pattern, n = Inf, simplify = FALSE)

Arguments

string

Input vector. Either a character vector, or something coercible to one.

pattern

Pattern to look for.

The default interpretation is a regular expression, as described in base::regex. Control options with regex().

Match a fixed string (i.e. by comparing only bytes), using fixed(). This is fast, but approximate.

n

Maximum number of pieces to return. Default (Inf) uses all possible split positions. This determines the maximum length of each element of the output.

simplify

A boolean.

  • FALSE (the default): returns a list of character vectors.

  • TRUE: returns a character matrix.

Value

A list the same length as string/pattern containing character vectors, or if simplify = FALSE, a character matrix with n columns and the same number of rows as the length of string/pattern.

Author(s)

Eli Pousson eli.pousson@gmail.com (ORCID)

Alexander Rossell Hayes alexander@rossellhayes.com (ORCID)

Source

Adapted from the stringr package.


stringstatic documentation built on July 26, 2023, 5:32 p.m.