[R] regular expression question
Greg.Snow at imail.org
Wed Mar 4 18:34:58 CET 2009
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)
 "(-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
greg.snow at imail.org
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of markleeds at verizon.net
> Sent: Monday, March 02, 2009 11:17 PM
> To: r-help at 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 :
> I tried to use strplit because of my regexpitis ( it's not curable.
> 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.
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help