title: code mirror : using regular expression
body: <p>I am trying to use regular expression for a simple mode in code mirror.</p>
  
  <p>My minimal code for testing it:</p>
  
  <pre><code>CodeMirror.defineMode("regex", function() {
    return {
      token: function(stream, state) {
      console.log(stream);
      a = stream.match(/word/);
      console.log(a);
      stream.skipToEnd();
      return null;
      }
    };
  });
  </code></pre>
  
  <p>The output of the first pass is:</p>
  
  <pre><code>Object { start: 74, pos: 74, string: "This is a sentence with word and key in it, and word and key are repeated.", tabSize: 4, lastColumnValue: 0, lastColumnPos: 0, lineStart: 0 } regex.js:5
  null
  </code></pre>
  
  <p>If I use the string "word" rather than the regex, it logs "undefined" instead of "null".</p>
  
  <p>Documentation of code mirror (<a href="http://codemirror.net/doc/manual.html" rel="nofollow">http://codemirror.net/doc/manual.html</a>) says (function match): </p>
  
  <blockquote>
    <p>pattern can be either a string or a regular expression starting with ^</p>
  </blockquote>
  
  <p>which is unclear to me (^ means 'not' for regex ?)</p>
  
  <p>It is the first time I use codemirror, regular expression and javascript, so I might be missing something obvious.</p>