Home >Web Front-end >JS Tutorial >Summary of commonly used regular expressions

Summary of commonly used regular expressions

一个新手
一个新手Original
2017-09-30 09:11:231840browse

Commonly used regular expressions:

 /^\w+([-+.']\w+)*\w+([-.]\w+)*\.\w+([-.]\w+)*$/ :电子邮箱
  /^1[0-9]{10}$/ : 手机号码11位
  /^(1[0-9]{10}|\w+([-+.']\w+)*\w+([-.]\w+)*\.\w+([-.]\w+))*$/ : 手机号码11位或者是电子邮箱

 ^[0-9a-zA-Z]+$: can only be pure numbers, pure letters or a combination of numbers and letters

 ^(?!\d+$)[\da-zA-Z]*$: It cannot be pure numbers, it can be pure letters, or it can be a combination of letters and numbers


var da = /^[0-9a-zA-Z]+$/;if (!da.test("需要匹配的字符串"))
{
  layer.tips('请输入数字和字母组合', $(this), { tips: [1, '#3595CC'], time: 4000 });
  Success = false;
}

The above is the detailed content of Summary of commonly used regular expressions. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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