[R] grepRaw() not matching fixed pattern at the tail
yui nishizawa
yui.nishizawa at gmail.com
Wed Jan 18 23:52:40 CET 2017
Hello
This is my first time posting a question.
I am having trouble getting grepRaw() to match a fixed pattern at the
tail of a raw vector.
Here is an example:
# Returns integer(0), expected 2.
grepRaw(pattern = charToRaw('abcd'), x = charToRaw('0abcd'), fixed=T)
# Consequently, the pattern won't match itself either. Returns integer(0).
grepRaw(pattern = charToRaw('abcd'), x = charToRaw('abcd'), fixed=T)
After some experiments, I noticed that these all work as expected:
# x doesn't end with the pattern. Returns 2 as expected.
grepRaw(pattern = charToRaw('abcd'), x = charToRaw('0abcd0'), fixed=T)
# A shorter pattern. length < 4?
grepRaw(pattern = charToRaw('abc'), x = charToRaw('0abc'), fixed=T)
# non-fixed.
grepRaw(pattern = charToRaw('abcd'), x = charToRaw('0abcd'), fixed=F)
However, I still need to get something like the top example to work.
Am I missing something?
Just in case, my sessionInfo() is:
R version 3.3.2 (2016-10-31)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: macOS Sierra 10.12.2
Any help is appreciated. Thank you.
Yui Nishizawa
More information about the R-help
mailing list