Re: [R] Is there a better way to parse strings than this?

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Thu, 14 Apr 2011 21:22:43 -0400

On Thu, Apr 14, 2011 at 8:28 PM, Chris Howden <chris_at_trickysolutions.com.au> wrote:
> Thanks for the suggestions, they were all exactly what I was looking for.
> (I knew that had to be a more elegant way then my brute force method)
>
> One question though.
>
> I was playing around with strsplit but couldn't get it to work, I realised
> my problem was that I was using "." as the string.
>
> I was trying strsplit(string,"\.\.\.") as per the suggestion in Venables
> and Ripleys book to "(use '\.' to match '.')", which is in the Regular
> expressions section.
>
> I noticed that in the suggestions sent to me people used:
> strsplit(test,"\\.\\.\\.")
>
>
> Could anyone please explain why I should have used "\\.\\.\\." rather than
> "\.\.\."?
>

"\\.\\.\\." is the string \.\.\. For example, try this

> cat("\\.\\.\\.\n")

\.\.\.

-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

______________________________________________
R-help_at_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.
Received on Fri 15 Apr 2011 - 01:25:32 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 15 Apr 2011 - 01:30:31 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive