title: CodeMirror simple mode - regex not highlighting as expected
body: <p>I'm trying to use <a href="http://codemirror.net/demo/simplemode.html" rel="nofollow noreferrer">CodeMirror simple mode</a> to create my own editor and highlight some custom keywords. However, it's highlighting occurrences of these words inside other words. Here's my code to define the mode of the editor:</p>
  <pre><code>    CodeMirror.defineSimpleMode(&quot;simple&quot;, {
    // The start state contains the rules that are intially used
    start: [
      // The regex matches the token, the token property contains the type
      {regex: /[&quot;'](?:[^\\]|\\.)*?(?:[&quot;']|$)/, token: &quot;string&quot;},
      {regex: /;.*/, token: &quot;comment&quot;},
      {regex: /\/\*/, token: &quot;comment&quot;, next: &quot;comment&quot;},
  
      {regex: /[-+\/*=&lt;&gt;!]+/, token: &quot;operator&quot;},
      {regex: /[\{\[\(]/, indent: true},
      {regex: /[\}\]\)]/, dedent: true},
  
      //Trying to define keywords here
      {regex: /\b(?:timer|counter|version)\b/gi, token: &quot;keyword&quot;} // gi for case insensitive
    ],
    // The multi-line comment state.
    comment: [
      {regex: /.*?\*\//, token: &quot;comment&quot;, next: &quot;start&quot;},
      {regex: /.*/, token: &quot;comment&quot;}
    ],
    meta: {
      dontIndentStates: [&quot;comment&quot;],
      lineComment: &quot;;&quot;
    }
  });
  </code></pre>
  <p>When I type in the editor, this is what gets highlighted. I would expect the first two occurrences to be styled, but not the second two.</p>
  <p><a href="https://i.stack.imgur.com/7FnqD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7FnqD.png" alt="enter image description here" /></a></p>
  <p>It's obviously something incorrect with this regular expression:</p>
  <pre><code>/\b(?:timer|counter|version)\b/gi
  </code></pre>
  <p>But I've tried it several different ways and the same pattern works correctly in other regex testers. Example:
  <a href="https://regex101.com/r/lQ0lL8/33" rel="nofollow noreferrer">https://regex101.com/r/lQ0lL8/33</a> . Any advice?</p>
  <h3>Edit #1:</h3>
  <p>Tried this pattern in codemirror definition, dropping the /g but it still yields the same incorrect highlighting.</p>
  <pre><code>{regex: /\b(?:timer|counter|version)\b/i, token: &quot;keyword&quot;}
  </code></pre>