Form Validation 2-js Regular

Source: Internet
Author: User

1. JS Regular: With/start, with/end.

Test function: Go inside to find, as long as there is inside, return true; otherwise it will return false.

For example: rep=/\d+/; Check if there are any numbers inside.

2.rep=/^ $/; Start and end characters

rep=/^\d+$/; The representation begins with a number, ends with a number

  

3. EXEC: Default returns only the first compliant value. returns only 123.

4.

\w: any letter or number or underscore, any of the a_za_z0_9,_.

\b: matches a word boundary, that is, the position between a word and a space .

Str= "Wangli7 houfan8 wangyun2"

' wang\w+ ': begins with Wang and is followed by any character.

'/bwang\w+/b ': begins with Wang and ends with any character. The default can only match the first one. #wangli7

'/bwang (\w+) +/b ': Begins with Wang and ends with any character. After the parentheses are added, the contents of the back are also matched. grouping (equivalent to a level two match, and then one match in the first match). #wangli7 Li7

5. Match all eligible. (Global Match)

/g global match, match successful one take 1. When all is done, return a null.

6.

1. Define Regular expressions

    • /.../for defining regular expressions
    • /.../g represents a global match
    • /.../i indicates case insensitive
    • /.../m means that multiple lines matching JS regular match is in itself a multi-line support, where the multiline match only affects the regular expression ^ and the $,m pattern will also use ^$ to match the contents of the newline)

Form Validation 2-js Regular

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.