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.


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.


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*$/,””);


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.

Leave a comment

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