re2_split: Split a string into pieces.

Description Usage Arguments Value Examples

Description

Split a string into pieces. Vectorised over string and pattern.

Usage

1
2
3
4
5
re2_split(string, pattern, n = Inf, parallel = FALSE, grain_size = 10000,
  ...)

re2_split_fixed(string, pattern, n, parallel = FALSE, grain_size = 10000,
  ...)

Arguments

string

a character vector

pattern

a character vector or pre-compiled regular expressions

n

number of pieces to return. Default (Inf) for re2_split uses all possible split positions. For re2_split_fixed, if n is greater than the number of pieces, the result will be padded with empty strings.

parallel

use multithread

grain_size

a minimum chunk size for tuning the behavior of parallel algorithms

...

further arguments passed to re2

Value

For re2_split_fixed, a character matrix with n columns.

For re2_split, a list of character vectors.

Examples

1
2
re2_split("yabba dabba doo", " ")
re2_split_fixed(c("yabba dabba doo", "a bc"), " ", 2)

Example output

[[1]]
[1] "yabba" "dabba" "doo"  

     [,1]    [,2]       
[1,] "yabba" "dabba doo"
[2,] "a"     "bc"       

re2r documentation built on May 2, 2019, 12:35 p.m.