13.1 Find simple matches with grep
- Find a pattern anywhere in the string (outputs the index of the element):
# By default, outputs the index of the element matching the pattern
grep(pattern="Gen",
x="Genomics")
- Show actual element where the pattern is found (instead of the index only) with value=TRUE:
- Non case-sensitive search with ignore.case=TRUE:
# Enter the pattern in lower-case, but case is ignored
grep(pattern="gen",
x="Genomics",
value=TRUE,
ignore.case=TRUE)
- Show if it DOESN’T match the pattern with inv=TRUE: