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

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to