Is it possible to use an AND operator in grepl()?

Viewed 12629

I want to search for anything that begins with 55 and anything that has the word Roof (case-sensitive, for those who are curious) in it.

So far I have been unsuccessful, as I can only seem to use the OR operator:

grepl("*^55|*Roof", dataset$longname)

Ultimately, I want to achieve something like this:

grepl("*^55&&*Roof", dataset$longname)

or

grepl("*^55&*Roof", dataset$longname)

(Clearly, neither of these work - they're for illustration only.)

I want my results to show anything that begins with 55 and which has the word Roof anywhere in it.

For example, I would expect both of these results to be picked up by the grepl() function:

55 - Roof Structure

and

55-Wall to Roof

Is there an AND operator that can be used with grepl()?

2 Answers
Related