正则表达式

有价值的参考资料:
http://net.pku.edu.cn/~yhf/tao_regexps_zh.html

http://www.unibetter.com/deerchao/zhengzhe-biaodashi-jiaocheng-se.htm

正则表达式30分钟入门教程



应用:
在js的RegExp()对象和C#中使用正则表达式有注意转意符号
eg:
1、(匹配数字)var reg=new RegExp("^\\d+$","gi"); 等价 var reg=/^\d+$/;
2、过滤特殊字符:document.getElementById("TypeName").value.replace(/\'/gi,"''");
3、数字+字母:reg=/^\w+$/g;
 if(!reg.test(pwd.value)) { alert("密碼格式錯誤!"); pwd.focus(); return false;}

posted @ 2007-07-27 14:08  Microbar  阅读(297)  评论(0编辑  收藏  举报