replace last occurance of element string js code example Example: javascript replace last character var str1 = "Notion,Data,Identity,".replace(/.$/,".")