 <p>Put what you want to exclude inside a negative lookahead in front of the match. For example,</p> <ul> <li><p>To match all punctuations apart from the question mark,</p> <pre><code>/(?!\?)[[:punct:]]/ </code></pre></li> <li><p>To match all words apart from <code>"go"</code>,</p> <pre><code>/(?!\bgo\b)\b\w+\b/ </code></pre></li> </ul>