title: Unable to run nools
body: <p>Hi I'm working on nools in node.js. When I run this program an error occurred: </p>
  
  <blockquote>
    <p>throw new Error("Invalid expression '" + expression + "'") Invalid expression 'm.text = ~/^hello(\s*world)?$/' pls help to fix this problem.</p>
  </blockquote>
  
  <p>Here my Code:</p>
  
  <p>Server.js</p>
  
  <pre><code>var express        =         require("express");
  var bodyParser     =         require("body-parser");
  var app            =         express();
  
  app.use(bodyParser.urlencoded({
      extended: true
  }));
  
  var index = 0;
  
  var nools = require("nools");
  
  var flow = nools.compile(__dirname + "/server/rules.nools");
  var Message = flow.getDefined("message");
  var session = flow.getSession();
  
  session.matchUntilHalt().then(
      function() {
          //all done!
          console.log("All done!");
      },
      function(err) {
          console.log("Error matchUntilHalt()", err.stack);
      }
  );
  
  app.post('/fact', function(req, res) {
      var key = req.body.key;
  
      console.log("\n" + ++index + " New fact", key);
  
      var newMsg = new Message(key);
  
      session.assert(newMsg);
  
      res.end("All OK");
  });
  
  app.get('/', function(req, res) {
      res.end("Watsup! Its " + new Date());
  });
  
  app.listen(4000, function() {
      console.log("Started up!");
  });
  </code></pre>
  
  <p>rools.nools</p>
  
  <pre><code>define Message {
      text: '',
      constructor: function(message) {
          this.text = message;
      }
  }
  
  //find any message that starts with hello
  rule Hello {
      when {
          m: Message m.text = ~/^hello(\s*world)?$/;
      }
      then {
          console.log("Hello rule fired.");
      }
  }
  
  //find all messages then end in goodbye
  rule Goodbye {
      when {
          m: Message m.text = ~/.*goodbye$/;
      }
      then {
          console.log("Goodbye rule fired.");
      }
  }
  
  define Client {
      age: 0,
      constructor: function(age) {
          this.age = age;
      }
  }
  
  rule CheckAge {
      when {
          // Multiple conditions in same rule
          c: Client c.age &gt; 30 &amp;&amp; c.age &lt; 65
      }
      then {
          console.log("Eligible for loan");
      }
  }
  </code></pre>