20150424 Regular Expressions

Source: Internet
Author: User

Regular expression Validation:
e-mail, Social Security number, postcode, telephone, mobile phone number

Mailbox:
1. Has and can only contain one @.
[email protected] at least one of the following.
3. Cannot begin with @ and. Cannot end with them.
[email protected] and. Must have at least one character.
5. If there are multiple. Words, they cannot be together.

Steps to validate with regular expressions:
1. Write the regular expression.
2. Take the value of the string to validate.
3. Use the match () method of the string to determine whether the string satisfies the regular expression.

var reg =/^ (\d{15}|\d{18}) $/; Regular expressions
var email = "370111199203059087";
if (Email.match (reg) = = null)
{
Alert ("Wrong ID format");
}
Else
{
Alert ("The identity card format is correct");
}

Qualifier for regular Expressions:--can read regular expressions.
1. Regular expressions are not quoted, but instead are used//.
2.^--the beginning of the match. $--matches the end.
3.\d-Match a number
4.\w-Match a letter or number
5.{m,n}-repeats the previous expression at least m times, repeating up to n times.
6.{m,}-repeats the previous expression at least m times, up to an unlimited number.
7.{M}-Repeats the previous expression m times
8.[8,5,2]-This position can only have one of the 8,5,2. 8,5,2 number of values and number of their own choice.
9.[0-9]-equivalent to \d
10.[A-Z,A-Z,0-9] equivalent to \w
11.+ equivalent to {1,}
12.* equivalent to {0,}
13. Equivalent to {0,1}
14. Priority ()
15. Escape \.


Simplified mailbox: \w+[@]\w+ ([.] \w+) {A}
Postcode: [1-9]\d{5}
ID number: [1-9]\d{16}[0-9,x]
Phone Number: (\d{3,4}[-]|\ (\d{3,4}\))? \d{7,8}

0533-3113118 (0533) 3113118010-23456789

20150424 Regular Expressions

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.