Saturday 15 January 2011

regex - Grep in R using AND -


Is there a way to put two words in grep for search?

Imagine I wanted to find items in an object for both "five" and "six", like "five" and "six".

  grep ("five" and "six", object)  

This will not work, I know that there is a connection with or with.

Lookahead is not required to do this, using the operator Can reference

  grep ('five * * six * * *, object)  

If you know that "five" before the "six" line , You do not even need options:

  grep ('five * .6', object)  

No comments:

Post a Comment