r - Using gsub instead of strsplit or scan -
are there other possibilities split string instead of?
unlist(strsplit("1.2.3", "[.]")) scan(text="1.2.3", what="", sep=".")
out of r's pattern matching functions base package (see ?gsub
), gregexpr
right 1 use here. identify start , end positions of chunks of characters not .
, can reconstruct them using regmatches
:
x <- "1.2.3.4as.zz2.zzxd3" regmatches(x, gregexpr("[^.]+", x))[[1]] # [1] "1" "2" "3" "4as" "zz2" "zzxd3"
but really, don't see gain on using strsplit
. if tell not it, maybe of more help.
Comments
Post a Comment