Re: [Rd] grep with fixed=TRUE and

From: Gabor Grothendieck <>
Date: Mon, 07 May 2007 10:37:30 -0400

Seems like a good idea to me.

Here is a workaround that works in any event which combines (?i), \Q and \E . to get the same effect. (?i) gives case insensitive matches and \Q and \E quote and endquote the intervening text disabling special characters:

x <- c("D.G cat", "d.g cat", "dog cat")
z <- "d.g"

rx <- paste("(?i)\\Q", z, "\\E", sep = "") grep(rx, x, perl = TRUE) # 1 2

On 5/7/07, Petr Savicky <> wrote:
> Dear R developers,
> I suggest to modify the behaviour of "grep" function with fixed=TRUE option.
> Currently, fixed=TRUE implies (overrides,
> if set by the user).
> I suggest to keep as set by the user even if fixed=TRUE. Since
> the default of is FALSE, this would not change the behaviour
> of grep, if the user does not set explicitly.
> In my opinion, fixed=TRUE is most useful for suppressing meta-character
> expansion. On the other hand, for a simple word search, ignoring
> case is sometimes useful.

> If for some reason, it is better to keep the current behavior of grep, then I
> suggest to extend the documentation as follows:
> fixed: logical. If 'TRUE', 'pattern' is a string to be matched as
> is. Overrides all conflicting arguments.
> fixed: logical. If 'TRUE', 'pattern' is a string to be matched as
> is. Overrides all conflicting arguments including
> All the best, Petr Savicky.
> ______________________________________________
> mailing list
> mailing list Received on Mon 07 May 2007 - 14:44:12 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 07 May 2007 - 20:35:36 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.