参考地址:http://ulhoo.com/blog/?p=285
http://www.cnblogs.com/wangkangluo1/archive/2011/07/17/2108819.html
http://topic.csdn.net/u/20090104/23/4ddb686c-93aa-4189-9ded-9f0b7af61ed0.html
参考代码:
1
<script type="text/javascript">
var fendata="9,45|4,12|9,21|";
var pid='9';
var rstr =new RegExp(pid+",\\d{1,2}\\|","g");
alert(rstr);
alert(fendata.replace(rstr,''));
alert(fendata);
</script>
2
/*
*unicode编码和字符相互转化
*/
"要".charCodeAt() == 35201; //true,35201为10进制值
String.fromCharCode(35201) == "要"; //true,35201为10进制值
"\u89" + "81" == "要"; //false,值为"u8981",是由于"\u"会转义成"u"
//从unicode编码到字符的方法
eval("(\"\u89" + "81\")") == "要"; //true,8981为16进制值
结论:
var ins = String.fromCharCode(160);
ins = new RegExp(ins, "g");
s = s.replace(ins, "");
完