Dec 2, 2011

////

jQuery: remove / replace last occurence of a character in a string

Actually this is not jQuery, this is just a javascript regular expression:

var str='Explore, Design ,Develop';
//replace last occurence of comma into ' and '
str.replace(/,([^,]*)$/,' and $1'); //returns Explore, Design and Develop

0 Reactions to this post

Add Comment