彩虹天堂
技术源于生活
posts - 0,  comments - 2,  trackbacks - 0

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<script>
 //去除头尾空格
 String.prototype.trim = function(){
  var regs = /^\s+(.*?)\s+$/;
  return this.replace(regs,"$1");
 };

 var sTest ="   This is a  ";
 alert("["+sTest+"]");
 alert("["+sTest.trim()+"]");

 //替换用户输入的限制的词汇
 var regWords = /badword|shit/gi;
 var sInput = "This is your life using badword3ss and shit .";
 var filterWord = sInput.replace(regWords,"*****");
 alert(filterWord);

 //去除用户输入的HTML标签
 String.prototype.scriptHTML = function(){
  var reTag = /<(?:.|\s)*?>/g;
  return this.replace(reTag,"");
 };

 var sTest = "<html><title>xxxx</title></html>";
 alert(sTest.scriptHTML());
</script>
<BODY>

</BODY>
</HTML>

posted on 2008-05-20 22:38 bcterry 阅读(101) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航:
 

<2024年11月>
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567

留言簿

文章档案

搜索

  •  

最新评论