title: Replace characters using Regex positive/negative lookahead?
body: <p>I have this string : </p>
  
  <p><code>var a='abc123#xyz123';</code></p>
  
  <p>I want to build 2 regexes replace functions which : </p>
  
  <p>1) Replace all characters that <strong>do</strong> have a future <code>'#'</code> -  with <code>'*'</code>   (not including '#')</p>
  
  <p>so the result should look like : </p>
  
  <pre><code>'******#xyz123'
  </code></pre>
  
  <p>2) Replace all characters that <strong>do not</strong> have a future <code>'#'</code> -  with <code>'*'</code>   (not including '#')</p>
  
  <p>so the result should look like : </p>
  
  <pre><code>'abc123#******'
  </code></pre>
  
  <p>What have I tried  : </p>
  
  <p><em><a href="http://jsbin.com/OcEtAXa/2/edit" rel="nofollow">For the positive lookahead :</a></em> </p>
  
  <pre><code>var a='abc123#xyz123';
  alert(a.replace(/(.+(?=#))+/ig,'*'));  //*#xyz123 --wrong result since it is greedy...
  </code></pre>
  
  <p>Question : </p>
  
  <p>How can I make my regexes work  as expected ?</p>