From hpages at fhcrc.org  Sat Jan  6 05:41:48 2007
From: hpages at fhcrc.org (Herve Pages)
Date: Fri, 05 Jan 2007 20:41:48 -0800
Subject: [Rd] pb in regular expression with the character "-" (PR#9437)
In-Reply-To: <20070104211808.504803F03A@slim.kubism.ku.dk>
References: <20070104211808.504803F03A@slim.kubism.ku.dk>
Message-ID: <459F288C.5030701@fhcrc.org>

Hi all,

maechler at stat.math.ethz.ch wrote:
> 
> Consider my guesstimate:
> For 99% of all R users, the amount of time they need working
> pretty intensely with R before they find a bug in it, 
> is nowadays more than three years, and maybe even much more
> -- such as their lifetime :-)

Perhaps I belong to the 1% of unlucky users that don't have to
wait that long ;-)

  > nchar("?A", type = "bytes")
  [1] 3
  > nchar("?A", type = "chars")
  [1] 2

  OK

Now:

  > regexpr("A", "?A")
  [1] 2
  attr(,"match.length")
  [1] 1

  still OK

But:

  > regexpr("A", "?A", useBytes=TRUE)
  [1] 2
  attr(,"match.length")
  [1] 1

  not OK anymore (3 expected, not 2)

Let's try with fixed=TRUE:

  > regexpr("A", "?A", useBytes=TRUE, fixed=TRUE)
  [1] 3
  attr(,"match.length")
  [1] 1

  much better!

H.


> sessionInfo()
R version 2.5.0 Under development (unstable) (2007-01-05 r40386)
i686-pc-linux-gnu

locale:
LC_CTYPE=en_CA.UTF-8;LC_NUMERIC=C;LC_TIME=en_CA.UTF-8;LC_COLLATE=en_CA.UTF-8;LC_MONETARY=en_CA.UTF-8;LC_MESSAGES=en_CA.UTF-8;LC_PAPER=en_CA.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_CA.UTF-8;LC_IDENTIFICATION=C

attached base packages:
[1] "stats"     "graphics"  "grDevices" "utils"     "datasets"  "methods"
[7] "base"

but this happens also in 2.4.0 and 2.4.1.



[Rd] pb in regular expression with the character "-" (PR#9437)
Herve Pages