javascript正则表达式货币

I'm trying to remove the decimal values on a money value pulled from json feed:

if I have like: 150,000 I want to have just 150

ere's my code:

$.getJSON('/static/js/datatest.json', function (result){

  $.each(result.events, function(i, item){
    $('#isoContainer').append('<h3>&pound;<span class="value">' + item.value.replace(/\.0{0,2}$/, "") + '</span></h3>');               
  });   
});

Why this is not working item.value.replace(/\,0{0,3}$/, "") ?

Because you escape the comma, the correct version is

/,0{0,3}$/

or if it doesn't go to the end of line, just

/,0{0,3}/

EDIT:

if you can have nonzero values after the , this is the correct one instead

/,\d{0,3}/

EDIT 2:

Also check that in the 'culture' you are using the , means the start of decimal positions and not the thousands separator

The code you've supplied uses a . in the regex, not a ,

This works:

"150,000".replace(/,(0|00|000)$/, "") // "150"

$ signifies end of string, other than that, it's plain simple regex.

Why don't you use parseInt()?

> parseInt("150,000");
150
> parseInt("150.000");
150