trim: Trim whitespace

Description Usage Arguments Value Author(s) See Also Examples

Description

Trim whitespace from ends of character string

Usage

1
2
3
4
5

Arguments

str

character string

Value

character

Author(s)

Thomas P Harte

See Also

gsub

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# left trim:
cat(sprintf("'%s'\n", triml(" asdf qwerty \t")))
cat(sprintf("'%s'\n", triml("\tasdf qwerty \t")))
# right trim:
cat(sprintf("'%s'\n", trimr(" asdf qwerty \t")))
cat(sprintf("'%s'\n", trimr("\tasdf qwerty \t ")))
# left & right trim:
cat(sprintf("'%s'\n", trim(" asdf qwerty \t")))
cat(sprintf("'%s'\n", trim("\tasdf qwerty \t")))
cat(sprintf("'%s'\n", trim(" asdf qwerty \t")))
cat(sprintf("'%s'\n", trim("\tasdf qwerty \t ")))

tharte/tutils documentation built on Feb. 11, 2020, 9:17 a.m.