Article From:https://www.cnblogs.com/liuteacher/p/9971759.html

I. Regular expressions

      Metacharacters: Any character other than newline characters

       .   :    Match any character except newline accidentally

      /w : Match numbers, letters, underscores

      /s  :    Matching blank characters

      /b  :    Match the end of a word

      /d  :    Matching number

      /W :    Match except numbers, letters, underscores.

      /D  : Matching Digital Numbers

      /S  :  Matching Except Blank Characters

      ^    :     Start

      $    :     Ending

     [ ]    :     Character set

     [ ^ ]  :    Except for elements in character groups

    Quantifiers, also known as qualifiers

    *   { 0,n}

    +  { 1,   n}

    ?  { 0,   1}

     {p}    p second

     {p,}   pOne or more times

     {p,q}  From p to Q

     .  *   

     .  +

     .  * ?  :Commonly used by reptiles

      Group ()

      \ n Line feed

      \  \ n \ n

      \.

      \ /

      \ ?

II. Re module

       findall ()  Get everything that matches

       finditer()   Matches everything, returns the iterator

       search()   Search, find and return

       match()    Match, match from scratch

       r ” (?P<name>Regular) ”

 

Leave a Reply

Your email address will not be published. Required fields are marked *