str.split: Splits string vectors

Description Usage Arguments Value Examples

View source: R/stringtools.R

Description

Splits string vectors

Usage

1
2
## S3 method for class 'split'
str(str, pattern, first = FALSE, keep.match = FALSE, ...)

Arguments

str

a vector of strings

pattern

vector where splits take place

Value

A list with same length as str. Each list element i contains the split substrings from str[i]

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
## Not run: 
  str = "Hi\n\nyou!"
  str.split(str,"\n", keep.match=!TRUE)
  
  str <- c("aes_afe_f", "qwe.rty", "yui0op[3", "b")
  #split x on the letter e
  str  
  str.split(str, "e", keep.match=TRUE)
  str.split(str, "e", first=TRUE, keep.match=TRUE)
  
  str = c("aes_afe_fe")
  ignore.pos = cbind(1,3)
  str.split(str, "e", keep.match=TRUE, ignore.pos=ignore.pos)
  str.split(str, "e", first=TRUE,keep.match=TRUE, ignore.pos=ignore.pos)
  
  
  str = "abscde3823nsd34"
  str.split(str, "[a-z]*", fixed=FALSE, keep.match=TRUE)
  str.split(str, c("[a-z]*","d"), fixed=FALSE, keep.match=TRUE)
  
  str = c("abscde3823nsd34","8748274")
  str.split(str, c("[a-z]*","d"), fixed=FALSE, keep.match=TRUE)

## End(Not run)

skranz/stringtools documentation built on May 26, 2017, 12:16 p.m.