matcher = re.compile(
    """
    (.+?)
    (?:               
        (?=[^a-zA-Z0-9])       
    |   (?=[A-Z][a-z])         
    |   (?<=[a-z])(?=[A-Z])    
    |   (?<=[a-zA-Z])(?=[0-9]) 
    |   (?<=^1[sS][tT])         
    |   (?<=[^1][1][sS][tT])    
    |   (?<=^2[nN][dD])         
    |   (?<=[^1]2[nN][dD])      
    |   (?<=^3[rR][dD])         
    |   (?<=[^1]3[rR][dD])      
    |   (?<=1[123][tT][hH])     
    |   (?<=[04-9][tT][hH])     
    |   (?<=^1)(?=[a-zA-Z])(?![sS][tT])       
    |   (?<=[^1]1)(?=[a-zA-Z])(?![sS][tT])    
    |   (?<=^2)(?=[a-zA-Z])(?![nN][dD])       
    |   (?<=[^1]2)(?=[a-zA-Z])(?![nN][dD])    
    |   (?<=^3)(?=[a-zA-Z])(?![rR][dD])       
    |   (?<=[^1]3)(?=[a-zA-Z])(?![rR][dD])    
    |   (?<=1[123])(?=[a-zA-Z])(?![tT][hH])   
    |   (?<=[04-9])(?=[a-zA-Z])(?![tT][hH])   
    |   (?=$)                               
    )
"""
    , re.X)
Как Python выполняет цикл синтаксического анализа с привязкой \G?