[Rd] regex to match word boundaries

From: Gabor Grothendieck <ggrothendieck_at_myway.com>
Date: Thu 02 Dec 2004 - 13:05:59 EST

Can someone verify whether or not this is a bug.

When I substitute all occurrence of "\\B" with "X" R seems to correctly place an X at all non-word boundaries (whether or not I specify perl) but "\\b" does not seem to act on all complement positions:

> gsub("\\b", "X", "abc def") # nothing done
[1] "abc def"
> gsub("\\B", "X", "abc def") # as expected, I think
[1] "aXbXc dXeXf"
> gsub("\\b", "X", "abc def", perl = TRUE) # not as expected
[1] "abc Xdef"
> gsub("\\B", "X", "abc def", perl = TRUE) # as expected
[1] "aXbXc dXeXf"
> R.version.string # Windows 2000
[1] "R version 2.0.1, 2004-11-27"



R-devel@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Thu Dec 02 13:14:48 2004

This archive was generated by hypermail 2.1.8 : Fri 18 Mar 2005 - 09:01:56 EST