Re: [R] regex sulotion for seperating number and string

2008-03-05 Thread sun
Thanks all for the prompt answers!!! All works perfectly! up and running! Thanks! "jim holtman" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > This should do it for you: > >> x <- c("2564gc", "2367,GH", "2134 JHG") >> x.sep <- gsub("([[:digit:]]+)[ ,]*([[:alpha:]]+)", "\\1 \\2",

Re: [R] regex sulotion for seperating number and string

2008-03-05 Thread jim holtman
This should do it for you: > x <- c("2564gc", "2367,GH", "2134 JHG") > x.sep <- gsub("([[:digit:]]+)[ ,]*([[:alpha:]]+)", "\\1 \\2", x) > # now create separate values > strsplit(x.sep, " ") [[1]] [1] "2564" "gc" [[2]] [1] "2367" "GH" [[3]] [1] "2134" "JHG" > On 3/5/08, sun <[EMAIL PROTECTED]>

Re: [R] regex sulotion for seperating number and string

2008-03-05 Thread vincenzo . 2 . di-iorio
t; "HK" "BF" Cheers Vincenzo --- Vincenzo Luca Di Iorio Consultant PME User support - GSK R&D Limited ------------------- &q

Re: [R] regex sulotion for seperating number and string

2008-03-05 Thread Gabor Grothendieck
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, so

[R] regex sulotion for seperating number and string

2008-03-05 Thread sun
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 th