Cheatography
                https://cheatography.com
            
        
        
    
                   
                            
                    
        
        
            
    
        
                            
        
                
        
            
                                
            
                
                                                | Syntax
                        
                                                                                    
                                                                                            | . | Wildcard |  
                                                                                            | ^ | Start of a string |  
                                                                                            | $ | End of a string |  
                                                                                            | x* | 0+ repetitions of x |  
                                                                                            | x+ | 1+ repetitions of x |  
                                                                                            | x? | 0-1 repetitions of x |  
                                                                                            | x{m} | m repetitions of x |  
                                                                                            | x{m,n} | m-n repetitions of x, greedy |  
                                                                                            | x{m,n}? | m-n repetitions of x, non-greedy |  
                                                                                            | x|y | x OR y |  
                                                                                            | [^x] | NOT x |  
                                                                                            | \a | Literal 'a' |  
                                                                                            | x*{int} | 'x*' must be int long |  
                                                                                            | < x > < y > | Collocations of x and y |  
                                                                                            | <x> (<y>) | Only returns y |  Whitespace characters
                        
                                                                                    
                                                                                            | \n | newline |  
                                                                                            | \s | space |  
                                                                                            | \t | tab |  
                                                                                            | \e | escape |  
                                                                                            | \r | return |  Functions
                        
                                                                                    
                                                                                            | search() | Somewhere in string |  
                                                                                            | findall() | Somewhere in the string, non-overlapping |  
                                                                                            | match() | Beginning of string |  
                                                                                            | fullmatch() | Entire string |  Arguments: pattern, string, <flag=0> |  | Special escape characters
                        
                                                                                    
                                                                                            | \A | IS at start of string |  
                                                                                            | \b | IS at wordbreak |  
                                                                                            | \B | NOT at wordbreak |  
                                                                                            | \d | IS [0-9] |  
                                                                                            | \D | NOT [0-9] |  
                                                                                            | \s | White space characters |  
                                                                                            | \S | NOT white space characters |  
                                                                                            | \w | IS Unicode word character [a-ZA-Z0-9_] |  
                                                                                            | \W | NOT Unicode word character |  
                                                                                            | \Z | IS at end of string |  .format
                        
                                                                                    
                                                                                            | '{:n}'.format(x) | Prints x, padded with n whitespace |  
                                                                                            | {:<n} | Left justified |  
                                                                                            | {:>n} | Right justified |  
                                                                                            | {:.nf} | Show n decimal places |  
                                                                                            | '{:{width}}'.format('x', width=n) |  |  | Hierarchy
                        
                                                                                    
                                                                                            | 1 | Parenthesis | ( ) |  
                                                                                            | 2 | Counters | * + ? { } |  
                                                                                            | 3 | Sequences and anchors | ^ $ |  
                                                                                            | 4 | Disjunction | | |  Flags
                        
                                                                                    
                                                                                            | re.I | re.IGNORECASE |  
                                                                                            | re.M | re.MULTILINE | ^ $ match line boundaries |  
                                                                                            | re.X | re.VERBOSE | Ignores whitespace |  | 
            
                            
            
            
        
        
        
        
        
            
    
        
          
Created By
Metadata
Comments
No comments yet. Add yours below!
Add a Comment
Related Cheat Sheets
More Cheat Sheets by dogwith4shoes