Here is another approach that still uses strspit if you want to stay with that:

> tmp <- '(-0.791,-0.263].(-38,-1.24].(0.96,2.43]'
> strsplit(tmp, '\\.(?=\\()', perl=TRUE)
[[1]]
[1] "(-0.791,-0.263]" "(-38,-1.24]"     "(0.96,2.43]"   

This uses the Perl 'look-ahead' indicator to say only match on a period that is 
followed by a '(', but don't include the '(' in the match.

Hope this helps,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


> -----Original Message-----
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
> project.org] On Behalf Of markle...@verizon.net
> Sent: Monday, March 02, 2009 11:17 PM
> To: r-help@r-project.org
> Subject: [R] regular expression question
> 
> can someone show me how to use a regular expression to break the string
> at the bottom up into its three components :
> 
> (-0.791,-0.263]
> (-38,-1.24]
> (0.96,2.43]
> 
> I tried to use strplit because of my regexpitis ( it's not curable.
> i've
> been to many doctors all over NYC. they tell me there's no cure  )  but
> it doesn't work because there also dots inside  the brackets. Thanks.
> 
> (-0.791,-0.263].(-38,-1.24].(0.96,2.43]
> 
> ______________________________________________
> 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.

Reply via email to