javascript - How to remove a subString using Last index in Java Script? -


my string is

var str = "{ aaaa} bbb} ccc ] } ddd } eeee" 

i want newstring using last occurance of }

var newstring = "{ aaaa} bbb} ccc ] } ddd }" 

how it?

try use lastindexof:

var s = '{ aaaa} bbb} ccc ] } ddd } eeee';  alert( s.substring(0, s.lastindexof('}')+1));


Comments