Home > Web Front-end > JS Tutorial > Detailed explanation of some regular matching expressions in jQuery

Detailed explanation of some regular matching expressions in jQuery

小云云
Release: 2018-01-23 10:25:06
Original
2170 people have browsed it

本文主要为大家带来一篇详谈jQuery中的一些正则匹配表达式。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧,希望能帮助到大家。

jQuery常用正则匹配表达式


//整数
"^-?[1-9]\\d*$",

//正整数 
"^[1-9]\\d*$",

//负整数
intege2: "^-[1-9]\\d*$",

//数字
num: "^([+-]?)\\d*\\.?\\d+$",

//正数(正整数 + 0)
num1: "^[1-9]\\d*|0$",

//负数(负整数 + 0)
num2: "^-[1-9]\\d*|0$",

//浮点数
decmal: "^([+-]?)\\d*\\.\\d+$",

//正浮点数
decmal1: "^[1-9]\\d*.\\d*|0.\\d*[1-9]\\d*$",
  

//负浮点数
decmal2: "^-([1-9]\\d*.\\d*|0.\\d*[1-9]\\d*)$",
 

//浮点数
decmal3: "^-?([1-9]\\d*.\\d*|0.\\d*[1-9]\\d*|0?.0+|0)$",
 

//非负浮点数(正浮点数 + 0)
decmal4: "^[1-9]\\d*.\\d*|0.\\d*[1-9]\\d*|0?.0+|0$",
  

//非正浮点数(负浮点数 + 0)
decmal5: "^(-([1-9]\\d*.\\d*|0.\\d*[1-9]\\d*))|0?.0+|0$",
  

//邮件
email: "^\\w+((-\\w+)|(\\.\\w+))*\\@[A-Za-z0-9]+((\\.|-)[A-Za-z0-9]+)*\\.[A-Za-z0-9]+$",

//颜色
color: "^[a-fA-F0-9]{6}$",

//url
url: "^http[s]?:\\/\\/([\\w-]+\\.)+[\\w-]+([\\w-./?%&=]*)?$",

//仅中文
chinese: "^[\\u4E00-\\u9FA5\\uF900-\\uFA2D]+$",

//仅ACSII字符
ascii: "^[\\x00-\\xFF]+$",

//邮编
zipcode: "^\\d{6}$",

//手机
mobile: "^(13|15)[0-9]{9}$",

//ip地址
ip4: "^(25[0-5]|2[0-4]\\d|[0-1]\\d{2}|[1-9]?\\d)\\.(25[0-5]|2[0-4]\\d|[0-1]\\d{2}|[1-9]?\\d)\\.(25[0-5]|2[0-4]\\d|[0-1]\\d{2}|[1-9]?\\d)\\.(25[0-5]|2[0-4]\\d|[0-1]\\d{2}|[1-9]?\\d)$",

//非空
notempty: "^\\S+$",

//图片
picture: "(.*)\\.(jpg|bmp|gif|ico|pcx|jpeg|tif|png|raw|tga)$",

//压缩文件
rar: "(.*)\\.(rar|zip|7zip|tgz)$",

//日期
date: "^\\d{4}(\\-|\\/|\.)\\d{1,2}\\1\\d{1,2}$",

//QQ号码
qq: "^[1-9]*[1-9][0-9]*$",

//电话号码的函数(包括验证国内区号,国际区号,分机号)
tel: "^(([0\\+]\\d{2,3}-)?(0\\d{2,3})-)?(\\d{7,8})(-(\\d{3,}))?$",

//用来用户注册。匹配由数字、26个英文字母或者下划线组成的字符串
username: "^\\w+$",

//字母
letter: "^[A-Za-z]+$",

//大写字母
letter_u: "^[A-Z]+$",

//小写字母
letter_l: "^[a-z]+$",

//身份证
idcard: "^[1-9]([0-9]{14}|[0-9]{17})$"
Copy after login

相关推荐:

php与javascript正则匹配中文的方法实现详解

正则匹配密码只能是数字和字母组合字符串功能_正则表达式

php与javascript正则匹配中文的方法分享


The above is the detailed content of Detailed explanation of some regular matching expressions in jQuery. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template