Python base 8.0 regex regular Expressions-common regular expressions

Source: Internet
Author: User

I. Regular expressions commonly used in PythonTwo. Regular Expression Web site, can be online regular matchhttps://regex101.com/1. How to use and the regular introduction1 "." Matches any character that is any other than the line break (\ n)' * ' matches a previous character 0 or more times2 "\b Matching digital 0-93 "\d match non-digital [^\b]4 "\s match space character5 "\s matches non-whitespace characters [^\s]*6> \w Match word character [A-z] [a-z][0-9]7> \w matches non-word characters [^\w]9* Match the previous character 0 or unlimited times 10 "? Match the preceding character 0 or 1 times11 "{m} matches the previous character m times12 "{M,n} matches the previous character m times to N timesboth M and n can be omitted, and if the province is M, it will match the previous character 0 times to N timesif n is omitted, it matches m to infinityOmit M:{0,n}omit n:{m,0}. Match m times to Infinite times12 "^ with what what start 13 "$ with what what end14 "| Represents an arbitrary match between the left and right expressions. It is always too often to try to match the expression on the left, once successfula successful match skips the right expression. If | is not included in the (), then its scope is the entirethe regular expression. 15 "(...) The enclosed expression will be grouped, starting from the left side of the expression, each encounter a grouped leftbrackets ' (', number +1. In addition, the grouping expression as a whole can be followed by the number of words. TableThe | In-style | is only valid in this group. 16. Grouping of regular Expressions(?    P<name>, ...) Group, specifying an additional alias in addition to the original number\<number> refers to a string that is matched to a group that is numbered <number>. (? P=name) refers to the string that the alias of <name> is matched to.

Python base 8.0 regex regular Expressions-common 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.