I was trying to extract a substring not followed by "NOT" from a string. For exmaple:
if the string looks like "WKA NOT IN", then the substring should be NA if the string is "WKA abc", then return "WKA".
I tried the str_extract in R with look behind:
str_extract(pattern = "WKA (<!NOT)", string)
However, I still got "WKA" from "WKA NOT IN". I can set up rule to return NA by doing something like !grepl("WKA NOT IN", string)
, but I wonder if there's an easy way to do it? Thanks!