remove commo from a string (1)

How to remove last comma from a string Jquery ?

A. When we select multiple items which are comma separated then  there is last comma also appear.

Ex:

Value1, Value2, Value3,

But we don’t want last comma to be present there. According to need we have to remove last comma from the string.

Solution:

str= str.replace(/,\s*$/,””);

in this in palce of str we can place our own value

var str= Value1, Value2, Value3,

str1= str.replace(/,\s*$/,””);

alert(str1);

One comment on “How to remove last comma from a string Jquery ?

  • Bhargav , Direct link to comment

    Hello I’m Bhargav. thanks for sharing all your knowledge through this blog with us.
    which help developers like us alot. Keep write more interesting blogs.
    Thanks.

Leave a comment

Your email address will not be published. Required fields are marked *