assertFinalSlash: Make Sure that Strings End With Slash

View source: R/assertFinalSlash.R

assertFinalSlashR Documentation

Make Sure that Strings End With Slash

Description

Make Sure that Strings End With Slash

Usage

assertFinalSlash(x, method = 1L)

Arguments

x

vector of character

method

integer value specifying the implementation method. 1 (default): Find strings without ending slash and append slash to these strings. 2: Remove one or more slashes at the end and append slash to all strings. 3: Append slash to all strings and replace multiple occurrences of slash at the end with one slash. Method 1 is the fastest but does not replace multiple trailing slashes with only one trailing slash (see examples).

Examples

assertFinalSlash(c("a", "b", "c"))
assertFinalSlash(c("a/", "b/", "c/"))
assertFinalSlash(c("a//", "b", "c/"))

# Use method 2 or 3 to replace multiple slashes with one slash
assertFinalSlash(c("a//", "b", "c/"), method = 2)
assertFinalSlash(c("a//", "b", "c/"), method = 3)

KWB-R/kwb.utils documentation built on April 1, 2024, 7:12 a.m.