JS Latest mobile phone number, ID card regular expression

Source: Internet
Author: User

Regular expressions (regular expression) are an object that describes the character pattern. Use regular expressions to perform powerful pattern matching and text retrieval and replacement functions.

ID Card Regular:

//身份证正则表达式(15位)isIDCard1=/^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$/;//身份证正则表达式(18位)isIDCard2=/^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{4}$/;身份证正则合并:(^\d{15}$)|(^\d{17}([0-9]|X)$)

The latest mobile phone number regular expression:

var tel = $("#telNo").val(); //获取手机号var telReg = !!tel.match(/^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/);//如果手机号码不能通过验证if(telReg == false){ }

Other

提取信息中的网络链接:(h|H)(r|R)(e|E)(f|F) *= *(‘|")?(\w|\\|\/|\.)+(‘|"| *|>)?提取信息中的邮件地址:\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*提取信息中的图片链接:(s|S)(r|R)(c|C) *= *(‘|")?(\w|\\|\/|\.)+(‘|"| *|>)?提取信息中的IP地址:(\d+)\.(\d+)\.(\d+)\.(\d+)提取信息中的中国手机号码:(86)*0*13\d{9}提取信息中的中国固定电话号码:(\(\d{3,4}\)|\d{3,4}-|\s)?\d{8}提取信息中的中国电话号码(包括移动和固定电话):(\(\d{3,4}\)|\d{3,4}-|\s)?\d{7,14}提取信息中的中国邮政编码:[1-9]{1}(\d+){5}提取信息中的中国身份证号码:\d{18}|\d{15}提取信息中的整数:\d+提取信息中的浮点数(即小数):(-?\d*)\.?\d+提取信息中的任何数字 :(-?\d*)(\.\d+)?提取信息中的中文字符串:[\u4e00-\u9fa5]*提取信息中的双字节字符串 (汉字):[^\x00-\xff]*

Use:

The test () method looks in the string for the presence of the specified regular expression and returns a Boolean value that returns true if it exists, otherwise false.

var pattern = new RegExp(‘Box‘,‘i‘);var str = ‘box‘;alert(pattern.test(str)); //truevar pattern = /Box/i;var str = ‘box‘;alert(pattern.test(str)); //truevar pattern = /Box/i;var str = ‘This is a box‘;alert(pattern.test(str)); //true

JS Latest mobile phone number, ID card regular expression

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.