regex help splitting string on the hyphen and space characters in R -


i have string follows:

"ipf-plasma 1" 

i'd split on "-" , "\\s". tried following:

strsplit(cleandata[[1]][1,1], "-|s") 

however, gives,

    > strsplit(cleandata[[1]][1,1], "-|s") [[1]] [1] "ipf"  "pla"  "ma 1" 

why there split on "plasma"? , how fix it?

you had it... forgot slashes...

a <- "ipf-plasma 1" > strsplit(a, "-|s") [[1]] [1] "ipf"  "pla"  "ma 1"  > strsplit(a, "-|\\s") [[1]] [1] "ipf"    "plasma" "1"      

Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -