I'm struggling to put together a regular expression which could be described as "match a specific string, unless it is contained within another string".
Specifically, I'm looking to match the string "nox", but not when it is in the string "monoxide".
X <- 'match the string "nox", but not when it is in the string "monoxide".'
> gsub("\\bnox\\b", "HERE", X)
[1] "match the string \"HERE\", but not when it is in the string \"monoxide\"."