Python learning regular expression re module

Source: Internet
Author: User

The regular expression uses the RE module

Import re to begin calling the regular expression.

The usual regular has the following characters:.  ^  $  *  + ?  {}   []   \   | ()
.       matches any character other than \ n, and can match line breaks in Dotall mode. ^     matches the beginning of the string, matching the beginning of each line in multiline mode. [^]   matches content that does not contain certain strings. $      matches the content that ends with a string. *       matches 0 or more arbitrary characters. +      matches 1 or more arbitrary characters.      matches 0 or 1 arbitrary characters. {}      matching content can be similar to   *  + &nbsp, like:             {0,}  ==  *             {1,}  == +                     {0,1} == ?             {m,n}  matches the previous character M~n times.             {m}     matches the previous character m times. []      character set, the corresponding position can be in the character setAny character in a character set can be listed as a group, or it can be given a range, such as [ABC] or [A-c].          the first character, if it is ^, is reversed, such as  [^abc]  means other characters that are not ABC. \      the escape character so that the latter character becomes the original meaning. |       represents an arbitrary match between the left and right expressions. ( )      the enclosed expression as a grouping, starting from the left side of the expression to encounter each grouping of the opening parenthesis ' (', number +1.   Another grouping expression as a whole,         can be followed by a number of words. The |  in an expression is only valid in that group. (? P<name&gt, ...)      Group, specify an additional alias in addition to the original number.      (? P&LT;ID&GT;ABC) {2}


\d: Matches any decimal number equal to [0-9]

\d: Matches any non-numeric character equivalent to [0-9]

\s: Matches any white space character, equivalent to [\t\n\r\f\v]

\s: Matches any non-whitespace character equivalent to [^\t\n\r\f\v]

\w: Matches any alphanumeric character, equivalent to [a-za-z0-9]

\w: Matches any non-alphanumeric character equivalent to [^a-za-z0-9]

This article is from the "less stubborn" blog, please be sure to keep this source http://xushaojie.blog.51cto.com/6205370/1789406

Python learning regular expression re module

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.