My String is
var str = "{ aaaa} bbb} ccc ] } ddd } eeee"
I want newString as by using last occurance of }
var newString = "{ aaaa} bbb} ccc ] } ddd }"
How to do it?
Try to use lastIndexOf:
var s = '{ aaaa} bbb} ccc ] } ddd } eeee';
alert( s.substring(0, s.lastIndexOf('}')+1));
var newString = str.replace(/ \w+$/, '');