[R] Do grep() and strsplit() use different regex engines?
Jeff Newmiller
jdnewmil at dcn.davis.CA.us
Sat Jul 11 17:52:13 CEST 2015
"\\b" is a zero length match. strsplit seems to chop at least one character off the beginning of the string if it sees a match, and then it looks at the shortened string that remains and repeats.
---------------------------------------------------------------------------
Jeff Newmiller The ..... ..... Go Live...
DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go...
Live: OO#.. Dead: OO#.. Playing
Research Engineer (Solar/Batteries O.O#. #.O#. with
/Software/Embedded Controllers) .OO#. .OO#. rocks...1k
---------------------------------------------------------------------------
Sent from my phone. Please excuse my brevity.
On July 11, 2015 7:47:22 AM PDT, Bert Gunter <bgunter.4567 at gmail.com> wrote:
>I noticed the following:
>
>> strsplit("red green","\\b")
>[[1]]
>[1] "r" "e" "d" " " "g" "r" "e" "e" "n"
>
>> strsplit("red green","\\W")
>[[1]]
>[1] "red" "green"
>
>I would have thought that "\\b" should give what "\\W" did. Note that:
>
>> grep("\\bred\\b","red green")
>[1] 1
>## as expected
>
>Does strsplit use a different regex engine than grep()? Or more
>likely, what am I misunderstanding?
>
>Thanks.
>
>Bert
>
>
>Bert Gunter
>
>"Data is not information. Information is not knowledge. And knowledge
>is certainly not wisdom."
> -- Clifford Stoll
>
>______________________________________________
>R-help at 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.
More information about the R-help
mailing list