----- Original Message ----
> From: Megh Dal <megh700...@yahoo.com>
> To: r-h...@stat.math.ethz.ch
> Sent: Wed, August 4, 2010 4:04:06 AM
> Subject: [R] Spliting a text
> 
> Hi, I want to split a text to seperate numerical and non-numerical portions 
> of  
>that. For example suppose I have a text "abc 3456" and I want to split in 2  
>parts like "abc" & "3456".
> 
> Is there any function to do  that?
> 
> Thanks,

> full.string <- "abc 3456"
> letter.part <- sub("^([[:alpha:]]+).*$", "\\1", full.string); letter.part
[1] "abc"
> numeric.part <- sub("^[^0-9]+(.*)$", "\\1", full.string); numeric.part
[1] "3456"
>

______________________________________________
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.

Reply via email to