Is there a better way to parse strings than this?
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