count_pieces: Count Number of Parts in a String

Description Usage Arguments Value Examples

View source: R/sv.R

Description

Counts number of pieces of a string separated by a pattern. If it's an empty string, returns 0. If the pattern isn't found, returns 1. If the pattern is found once, returns 2 (two pieces), etc.

Usage

1
count_pieces(x, sep)

Arguments

x

Input string.

sep

Pattern to count for.

Value

Number of parts.

Examples

1
2
3
4
(a <- gpgr:::count_pieces("foo,bar,baz", sep = ","))
(b <- gpgr:::count_pieces("foo", sep = ","))
(k <- gpgr:::count_pieces("", sep = ","))
(m <- gpgr:::count_pieces(",", sep = ","))

umccr/gpgr documentation built on Nov. 25, 2021, 1:15 p.m.