But I don't want to ignore all regexp's -- I want to build a regexp which
contains string components which are parameters.

            -s

On Sat, Nov 29, 2008 at 6:51 PM, Gabor Grothendieck <ggrothendieck@gmail.com
> wrote:

> grep has a fixed = TRUE argument if you want to ignore all regexp's.
>
> On Sat, Nov 29, 2008 at 3:55 PM, Stavros Macrakis <macrakis@alum.mit.edu>
> wrote:
> > Hmm, this brings up an interesting question.  What if the string I'm
> looking
> > for contains escape characters?  For example, grep( paste( "^", "(ab)" ),
> > c("ab","(ab)") ) => c(1), not c(2).
> >
> > I couldn't find an equivalent to Emacs's regexp-quote, which would let me
> > write regexp.quote("(ab)") => "\\(ab\\)".  The syntax of regular
> expressions
> > is complicated enough that this is not trivial. Is there perhaps a CRAN
> > package with regular expression utilities?
> >
> >             -s
> >
> > On Sat, Nov 29, 2008 at 7:12 AM, Gabor Grothendieck
> > <ggrothendieck@gmail.com> wrote:
> >>
> >> > a <- 2:3
> >> > b <- c("aaa 2 aaa", "2 aaa", "3 aaa", "aaa 3 aaa")
> >> > re <- paste("^(", paste(a, collapse = "|"), ")", sep = "")
> >> > grep(re, b, value = TRUE)
> >> [1] "2 aaa" "3 aaa"
> >
> >
>

	[[alternative HTML version deleted]]

