Try this: > library(gsubfn) > x <- c("2324gz", "2567 HK", "3741,BF") > strapply(x, "[[:digit:]]+|[[:alpha:]]+") [[1]] [1] "2324" "gz"
[[2]] [1] "2567" "HK" [[3]] [1] "3741" "BF" On Wed, Mar 5, 2008 at 9:51 AM, sun <[EMAIL PROTECTED]> wrote: > I have strings contain postcode and letters, some seperated with blank, some > with comma, and some hasn't seperated. eg, "2324gz" "2567 HK" "3741,BF" > > I want to seperate the number and letters into two new variables. > > I know this should be quite basic question, but searched on regex syntax and > that seems a bit scarey to me, any one can shot me a quick solution on this > particular question? > > thanks, > Sun > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.