javascript--Regular Expressions

Source: Internet
Author: User

1. Explicitly create regular expressions: var searchpattern=new RegExp (' +s '); The plus sign matches any one of the strings with one or more contiguous s.

2. Methods forRegExp objects:test and exec

    • The test method determines whether the string passed in as a parameter matches the regular expression, and the return value is type bool.
    • The Exec return value is an array that matches the matching criteria.

3. The regular expression character used to match a particular occurrence of the character has four: the asterisk (*) matches the character in front of it 0 or more times, plus (+) matches the character in front of him one or more times, and say hello (?). Matches the character that precedes it 0 or 1 times. The dot (.) matches one character.

4.\d This sequence is a pattern for finding any non-numeric character ;\s is a blank character ;\d matches only numbers .

5. Use square brackets with a numeric range, preceded by an up arrow (^). If you want to match any non-numeric character, use the following pattern: [^0-9], equivalent to \d; the matching number is removed by the upper arrow ^,[0-9] equivalent to \d. If you want to match more than one character, you can list the range of each character in the middle of the square brackets [a-za-z]. Above the Upper arrow if the square brackets outside the match any one line starts , the $ symbol matches any one line to the end. If a multiline flag mis used, the UP arrow matches the first character after the line break. The above content shows that any match is. *.

6.the \w sequence matches any one letter and number , including underscores . \w is equivalent to any non-word character.

7,| The vertical bar indicates or means that the curly braces indicate the number of repetitions of the preceding character.

javascript--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.