Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

strexp

Expand String to Fixed Width


Description

Expand strings to a fixed ‘length’ (in the sense of nchar).

Usage

strexp(s, after, width, fill = " ", at)

Arguments

s

a character vector

after

character: a pattern, to be passed to regexpr

width

integer

fill

character

at

integer

Details

strexp inserts blanks into the elements of a character vector such that all elements have the same width (i.e. nchar). Note that it will (currently) not contract a string, only expand it.

Value

a character vector

Author(s)

Enrico Schumann

See Also

Examples

## expand to width 10, but keep two initial blanks 
s <- c("  A 1", "  B     2")
strexp(s, after = " +[^ ]+ +", width = 10)

textutils

Utilities for Handling Strings and Text

v0.2-1
GPL-3
Authors
Enrico Schumann [aut, cre] (<https://orcid.org/0000-0001-7601-6576>)
Initial release
2021-04-01

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.