From p.dalgaard@biostat.ku.dk  Tue Mar 14 11:33:38 2000
From: p.dalgaard@biostat.ku.dk (Peter Dalgaard BSA)
Date: 14 Mar 2000 12:33:38 +0100
Subject: [Rd] Bug in sub? (PR#487)
In-Reply-To: dtrenkler@nts6.oec.uni-osnabrueck.de's message of "Tue, 14 Mar 2000 12:16:27 +0100 (MET)"
References: <200003141116.MAA19358@pubhealth.ku.dk>
Message-ID: <x266up4wh9.fsf@blueberry.kubism.ku.dk>

dtrenkler@nts6.oec.uni-osnabrueck.de writes:

> I suspect that there is bug in sub when using "?":
> 
> > string_"This is a bug!"
> >  sub("!", ", or isn't it?", string)
> [1] "This is a bug, or isn't it?"
> > string_"This is a bug?"
> >  sub("?", ", or isn't it?", string)
> [1] "This is a bug?"

Hmm. If there is a bug it may not where you think...

'?' is an operator of extended regular expressions, so you're not
looking for a question mark there: 

>  sub("\\?", ", or isn't it?", string)
[1] "This is a bug, or isn't it?"

>  sub("?", ", or isn't it?", ext=F, string)
[1] "This is a bug, or isn't it?"

One might expect that a null RE would always match the beginning of a
string, but it doesn't...

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


[Rd] Bug in sub? (PR#487)
Peter Dalgaard BSA