Displaying 1 result from an estimated 1 matches for "02d_junk".
Did you mean:
00_junk
2010 Jan 21
0
unexpected behaviour of R-2.10.1 regular expression in UTF-8 locale
...countered the following unexpected behaviour of R-2.10.1, but not
R-2.9.0,
on both RHEL 4 and Ubuntu Karmic (precompiled via synaptic or built from
source).
I have a character vector from which I want to extract a certain pattern
that is surrounded
by junk as in:
> nn <- sprintf("junk_%02d_junk", 1:2)
> nn
[1] "junk_01_junk" "junk_02_junk"
> sub("^.*([[:digit:]]{2}).*$", "\\1", nn)
[1] "nk" "nk"
# oops? however:
> sub("^.*([[:digit:]]{2}).*$", "\\1", nn, perl = TRUE)
[1] "01" "02...