title: JavaScript Regular Expression: Non-Digit Character
body: <p>How do I say remove a number preceded by a non-digit and followed by a dash, but leave the preceding non-digit character?</p>
  
  <pre><code>RegExp: /[^\D]4\-/
  String: http://localhost/images/4-6-.png
  Remove: 4-
  </code></pre>
  
  <p>The <code>4-</code> should be removed and it should leave the preceding <code>/</code> or <code>-</code></p>
  
  <p>This would work: <code>/4\-/</code><br>
  But it would also remove <code>14-</code> or <code>44-</code></p>
  
  <h2>Dynamic Code:</h2>
  
  <p><a href="http://jsfiddle.net/flackend/8s9X9/2/">http://jsfiddle.net/flackend/8s9X9/2/</a></p>
  
  <h2>Static Code:</h2>
  
  <pre><code>var category_id = 4;
  var src         = 'http://localhost/images/4-6-.png';
  var regexp      = new RegExp('[^\\D]'+ category_id +'\\-')
  
  $('p').append('regexp: '+ regexp +'&lt;br&gt;');
  $('p').append(src +'&lt;br&gt;');
  
  src = src.replace(regexp, '');
  
  $('p').append(src);
  </code></pre>