How do I use grepl to specify an exact match of my word from string BUT allow semicolon?

That is not how grepl works, it is going to retrieve the entire line where the pattern is found, it doesn't extract subsets o a single character string.

I think you have to separate your string using the semicolons as delimiters, into a character vector, then you can match individual elements.

1 Like