<p>I am trying to write a replacement regular expression to surround all words in quotes except the words AND, OR and NOT. </p>

<p>I have tried the following for the match part of the expression:</p>

<pre><code>(?i)(?&lt;word&gt;[a-z0-9]+)(?&lt;!and|not|or)
</code></pre>

<p>and </p>

<pre><code>(?i)(?&lt;word&gt;[a-z0-9]+)(?!and|not|or)
</code></pre>

<p>but neither work. The replacement expression is simple and currently surrounds all words.</p>

<pre><code>"${word}"
</code></pre>

<p>So </p>

<blockquote>
  <p>This and This not That</p>
</blockquote>

<p>becomes </p>

<blockquote>
  <p>"This" and "This" not "That"</p>
</blockquote>

This is a little dirty, but it works:
```
```
(?<!\b(?:and| or|not))\b(?!(?:and|or|not)\b)
```
```
In plain English, this matches any word boundary not preceded by and not followed by "and", "or", or "not". It matches whole words only, e.g. the position after the word "sand" would not be a match just because it is preceded by "and".
The space in front of the "or" in the zero-width look-behind assertion is necessary to make it a fixed length look-behind. Try if that already solves your problem.
EDIT: Applied to the string "except the words AND, OR and NOT." as a global replace with single quotes, this returns:
```
```
'except' 'the' 'words' AND, OR and NOT.
```
```