0
var asdf = "a[3] > b[5] > c[1]"
function removebracket(){
var newstring = asdf.replace(/\/[^\/]*$/, '')
alert(newstring);
}
<a href="#" onClick="javascript:removebracket();"> remove square brackets one by one </a>
實際上我需要刪除每次迭代的最後一個方括號 – gwegwegw 2009-10-31 00:15:09