<script type="text/javascript">
String.prototype.format = function () {
var values = arguments;
return this.replace(/([^\{])?\{(\d+)\}(?!\})/g, function ($0, prefix, pos) {
//alert(pos);
pos = parseInt(pos);
return (prefix || "") + values[pos];
});
}
//使用方法
alert("name:{0}, sex:{1}".format("sss", "''(){'"));
alert("{0}, sex:{1}".format("sss", "''(){'"));
</script>