title: Regular expression to strip thousand separator from numeral string?
body: <p>I have strings which contains thousand separators, however no string-to-number function wants to consume it correctly (using JavaScript). I'm thinking about "preparing" the string by stripping all thousand separators, leaving anything else untoched and letting <code>Number</code>/<code>parseInt</code>/<code>parseFloat</code> functions (I'm satisfied with their behavious otherwise) to decide the rest. But it seems what i have no idea which RegExp can do that!</p>
  
  <p>Better ideas are welcome too!</p>
  
  <hr>
  
  <h2>UPDATE:</h2>
  
  <p>Sorry, answers enlightened me how badly formulated question it is. What i'm triyng to achieve is: 1) to strip thousand separators only if any, but 2) to not disturb original string much so i will get NaNs in the cases of invalid numerals.</p>
  
  <h2>MORE UPDATE:</h2>
  
  <p>JavaScript is limited to English locale for parsing, so lets assume thousand separator is ',' for simplicity (naturally, it never matches decimal separator in any locale, so changing to any other locale should not pose a problem)</p>
  
  <p>Now, on parsing functions:</p>
  
  <pre><code>parseFloat('1023.95BARGAIN BYTES!')  // parseXXX functions just "gives up" on invalid chars and returns 1023.95
  Number('1023.95BARGAIN BYTES!')      // while Number constructor behaves "strictly" and will return NaN
  </code></pre>
  
  <p>Sometimes I use rhw loose one, sometimes strict. I want to figure out the best approach for preparing string for both functions.</p>
  
  <p>On validity of numerals:</p>
  
  <p><code>'1,023.99'</code> is perfectly well-formed English number, and stripping all commas will lead to correct result.
  <code>'1,0,2,3.99'</code> is broken, however generic comma stripping will give <code>'1023.99'</code> which is unlikely to be a correct result.</p>