Day of the Python regular expression

Source: Internet
Author: User

Tag: expression returns the specified any regular module digital print class

Re module \ Regular expression one, meta-character

1,. ^ $ * + ? { } [ ] | ( ) \

"."  Represents (any one character) "*" for (any number of arbitrary characters, 0-Infinity) "+" stands for (any one or no number, 1-infinity) "?" Represents (0 or 1 characters) "^" for (beginning of String) "$" for (end of String) "{}" representation (specified number of times)

2. Escape character \

1), backslash followed by meta-character removal of special functions, such as \.

2), back slash behind with ordinary characters to achieve special functions, such as \d

\d  matches any decimal number;      it is equivalent to class [0-9]. \d  matches any non-numeric character;    it is equivalent to class [^0-9]. \s  matches any whitespace character;      it is equivalent to class [\t\n\r\f\v]. \s  matches any non-whitespace character;    it is equivalent to class [^ \t\n\r\f\v]. \w  matches any alphanumeric character;   it is equivalent to class [a-za-z0-9_]. \w  matches any non-alphanumeric character; it is equivalent to a class [^a-za-z0-9_]\b  matches a special character boundary, such as a space, &,#, etc.

3. Group ()

ret = Re.findall ("(yuan) +", "Lalal11yuanhao22yuanyuanhaohao33yuan") #分组 (), returned with the FindAll command is a grouped content print (ret) #[' yuan ', ' Yuan ', ' yuan ']

  

Day of the Python regular expression

Related Article

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.