didasoft

转贴:匹配中文的正则表达式及其他

想匹配中文,请将pattern表达式设为:[\u4e00-\u9fa5]

想排除中文,请将pattern表达式设为:[^\u4e00-\u9fa5]

下面是一些转载来的正则

用正则表达式限制只能输入中文:onkeyup="value=value.replace(/[^\u4E00-\u9FA5]/g,\'\')" onbeforepaste="clipboardData.setData(\'text\',clipboardData.getData(\'text\').replace(/[^\u4E00-\u9FA5]/g,\'\'))"

用正则表达式限制只能输入全角字符: onkeyup="value=value.replace(/[^\uFF00-\uFFFF]/g,\'\')" onbeforepaste="clipboardData.setData(\'text\',clipboardData.getData(\'text\').replace(/[^\uFF00-\uFFFF]/g,\'\'))"

用正则表达式限制只能输入数字:onkeyup="value=value.replace(/[^\d]/g,\'\') "onbeforepaste="clipboardData.setData(\'text\',clipboardData.getData(\'text\').replace(/[^\d]/g,\'\'))"

用正则表达式限制只能输入数字和英文:onkeyup="value=value.replace(/[\W]/g,\'\') "onbeforepaste="clipboardData.setData(\'text\',clipboardData.getData(\'text\').replace(/[^\d]/g,\'\'))"

发表于 2007-09-05 09:03  深圳杰瑞  阅读(290)  评论(0编辑  收藏  举报
 

分类:

技术点:

相关文章:

  • 2021-11-17
  • 2022-12-23
  • 2021-11-17
  • 2022-03-05
  • 2021-05-27
  • 2021-06-01
猜你喜欢
  • 2021-11-17
  • 2022-12-23
  • 2021-12-06
  • 2021-11-17
  • 2021-11-17
  • 2021-11-17
相关资源
相似解决方案