str_split_2: strsplit 2.0 by Jakob Gepp

View source: R/str_split_2.R

str_split_2R Documentation

strsplit 2.0 by Jakob Gepp

Description

Splits the string but keeps the delimiter. Adopted from https://www.statworx.com/de/blog/strsplit-but-keeping-the-delimiter/.

Usage

str_split_2(x, split, type = "remove", perl = FALSE, ...)

Arguments

x

A character vector or string

split

What to split the string by

type

Select one of type = c("remove", "before", "after")

perl

Extended results expresions are the default perl = FALSE and Perl-like regular expression with perl = TRUE

...

Other arguments

Details

A regular expression is a pattern that describes a set of strings. Two types of regular expressions are used in R, extended regular expressions (the default) and Perl-like regular expressions used by perl = TRUE. There is a also fixed = TRUE which can be considered to use a literal regular expression.

Value

A list of characters

Examples

x <- c("3D/MON&SUN")
str_split_2(x, "(?<=.)(?=[/&])",perl = TRUE)

a <- c("asdasd.sss","segssddfge.sss","se.sss")
str_split_2(x = a, split = "[.]", type = "remove", perl = TRUE)


emilelatour/lamisc documentation built on April 9, 2024, 10:33 a.m.