Skip to content
Back to formatted view

Raw Message

Message-ID: <BANLkTim0KJY=57G6A+R9Yjx_P-uwymdyiw@mail.gmail.com>
Date: 2011-04-15T01:07:10Z
From: Hadley Wickham
Subject: Is there a better way to parse strings than this?
In-Reply-To: <97b340f6446f8fca9227834cc1429379@mail.gmail.com>

> 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
> "\.\.\."?

Basically,

 * you want to match .
 * so the regular expression you need is \.
 * and the way you represent that in a string in R is \\.

Hadley

-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/