JS Regular expression

Source: Internet
Author: User
Tags faa

Note: \ r \ n Indicates carriage return line, \ n = newline, \ r = Carriage return (but no line wrapping when output string)

  1. \d any number, any one of the 0~9;

    \w any one letter or number or underscore, i.e. any of the a~z,a~z,0~9,_;

    \s any of the white space characters, such as spaces, tabs, and page breaks;

    The decimal point can match any character except the line break (/n);

    \ t represents a tab character;

    \b Matches a word boundary, that is, the position between the word and the space, does not match any character , each word is counted on both sides, only matches but does not replace, such as the character ABA Fhaud FAA in (/\b/g, "#") for #aba# #fhaud # #faa #;

    ^ matches where the string starts, does not match any characters

    $ matches the place where the string ends, does not match any characters
  2. [] contains a series of characters that can match any one of these characters and can only be one. With [^] contains a series of characters, it is able to match any character other than the character.

    [[email protected]] matches "a" or "B" or "5" or "@";

    [^ABC] matches any character except "A", "B", "C"

    [F-k] matches any one of the letters between "F" ~ "K"

    [^a-f0-3] matches any character except "a" ~ "F", "0" ~ "3"
  3. {n} expression repeats n times, for example: "/w{2}" equals "/w/w"; "A{5}" equals "AAAAA"

    {m,n} expression repeats at least m times and repeats up to n times, for example: "ba{1,3}" can match "ba" or "Baa" or "baaa"

    {m,} The expression repeats at least m times, for example: "/w/d{2,}" can match "A12", "_456", "M12344" ...

    Match expression 0 or 1 times, equivalent to {0,1}, for example: "A[CD]?" Can match "a", "AC", "AD"

    + expression appears at least 1 times, equivalent to {1,}, for example: "A+b" can match "AB", "AaB", "Aaab" ...

    * expression does not appear or appear any time, equivalent to {0,}, for example: "/^*b" can match "B", "^^ ^b" ...
  4. The "or" relationship between the left and right sides of the expression

    () The expressions in parentheses can be matched individually, in an expression that has an expression like |

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