title: regexp replace '1x' and '1x²' with 'x' and 'x²' (javascript)
body: <p>I'm trying to replace every '1x' and '1x²' in a mathematical string with 'x' and 'x²' :</p>
  
  <pre><code>var str = '1x² + (1x − 11x)(1x² + 1x²)'; //string to be parsed
  var reg = str.replace(/1x/g, 'x');
  console.log(reg);
  </code></pre>
  
  <p>Problem is my regexp also matches numbers like '11x' or '21x', which is obviously not what I want. So my code currently outputs <code>x² + (x − 1x)(x² + x²)</code> instead of <code>x² + (x − 11x)(x² + x²)</code>.</p>
  
  <p>I know why I get this behaviour, but I don't know how to fix it. How can I get my regexp to match every 1x and 1x² if and only if they are not preceded by another number like '11x' or 221x²' ?</p>