title: JavaScript and regular expressions: literal syntax Vs. RegExp object
body: <p>I have some troubles with this small JavaScript code:</p>
  
  <pre class="lang-js prettyprint-override"><code>var text="Z Test Yeah ! Z";
  
  // With literal syntax, it returns true: good!
  alert(/(Z[\s\S]*?Z)/g.test(text));
  
  // But not with the RegExp object O_o
  var reg=new RegExp('Z[\s\S]*?Z','g');
  alert(reg.test(text));
  </code></pre>
  
  <p>I don't understand why the literal syntax and the RegExp object don't give me the same result...
  The problem is that I have to use the RegExp object since I'll have some variables later.</p>
  
  <p>Any ideas?</p>
  
  <p>Thanks in advance :)</p>