javascript的一些常用正则表达式
2006-07-26 14:42
639 查看
匹配中文字符的正则表达式: [/u4e00-/u9fa5]
匹配双字节字符(包括汉字在内): [^/x00-/xff]
匹配空行的正则表达式: /n[/s| ]*/r
匹配HTML标记的正则表达式: /<(.*)>.*<///1>|<(.*) //>/
匹配首尾空格的正则表达式: (^/s*)|(/s*$)(像vbscript那样的trim函数)
匹配Email地址的正则表达式: /w+([-+.]/w+)*@/w+([-.]/w+)*/./w+([-.]/w+)*
匹配网址URL的正则表达式: http://([/w-]+/.)+[/w-]+(/[/w- ./?%&=]*)?
利用正则表达式限制网页表单里的文本框输入内容:
1.用正则表达式限制只能输入中文:onkeyup="value=value.replace(/[^/u4E00-/u9FA5]/g,'')"
onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^/u4E00-/u9FA5]/g,''))"
2.用正则表达式限制只能输入全角字符: onkeyup="value=value.replace(/[^/uFF00-/uFFFF]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^/uFF00-/uFFFF]/g,''))"
3.用正则表达式限制只能输入数字:onkeyup="value=value.replace(/[^/d]/g,'') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^/d]/g,''))"
4.用正则表达式限制只能输入数字和英文:onkeyup="value=value.replace(/[/W]/g,'') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^/d]/g,''))"
<script type="text/javascript"><!--
google_ad_client = "pub-0068659036624865";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text_image";
google_ad_channel ="";
//--></script><script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
匹配双字节字符(包括汉字在内): [^/x00-/xff]
匹配空行的正则表达式: /n[/s| ]*/r
匹配HTML标记的正则表达式: /<(.*)>.*<///1>|<(.*) //>/
匹配首尾空格的正则表达式: (^/s*)|(/s*$)(像vbscript那样的trim函数)
匹配Email地址的正则表达式: /w+([-+.]/w+)*@/w+([-.]/w+)*/./w+([-.]/w+)*
匹配网址URL的正则表达式: http://([/w-]+/.)+[/w-]+(/[/w- ./?%&=]*)?
利用正则表达式限制网页表单里的文本框输入内容:
1.用正则表达式限制只能输入中文:onkeyup="value=value.replace(/[^/u4E00-/u9FA5]/g,'')"
onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^/u4E00-/u9FA5]/g,''))"
2.用正则表达式限制只能输入全角字符: onkeyup="value=value.replace(/[^/uFF00-/uFFFF]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^/uFF00-/uFFFF]/g,''))"
3.用正则表达式限制只能输入数字:onkeyup="value=value.replace(/[^/d]/g,'') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^/d]/g,''))"
4.用正则表达式限制只能输入数字和英文:onkeyup="value=value.replace(/[/W]/g,'') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^/d]/g,''))"
<script type="text/javascript"><!--
google_ad_client = "pub-0068659036624865";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text_image";
google_ad_channel ="";
//--></script><script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
相关文章推荐
- javascript正则表达式中的一些常用模式
- JavaScript中一些常用的正则表达式(推荐)
- javascript的一些常用正则表达式
- 一些常用的JavaScript正则表达式
- javascript中常用的一些功能及正则表达式的用法
- JavaScript一些常用的正则表达式
- javascript 中一些常用的正则表达式
- 分享一些javascript与正则表达式常用的调试工具
- JavaScript 正则表达式常用的转义符
- 常用的JavaScript验证正则表达式
- 常用的JavaScript验证正则表达式
- 常用的JavaScript验证正则表达式
- JavaScript常用的正则表达式应用(ip,email,data,time)
- javascript的正则表达式语法和常用方法说明
- 常用的一些字符串处理 及正则表达式
- 【JavaScript 学习--01】--常用正则表达式
- PHP和javascript常用正则表达式及用法实例
- 开发中常用的正则表达式大全——包括校验数字、字符、一些特殊的需求等
- 最全的常用正则表达式大全——包括校验数字、字符、一些特殊的需求等等