Regular idetifying repeatative patterns
Question: My data patterns looks like below,

    
    
    t_hat_1
    t_hat_2
    t_hat_3
    name
    s_flower_1
    s_flower_2
    s_flower_3
    s_flower_22
    s_flower_23
    address
    

I need to identify all the repeating matches like t_hat_1,2,3 &
s_flower_1,2,3,22,23...I don't have the fixed number of repeatative items..for
example:-hat will have [1-3] and flower[1-50]

What would be the most efficient way to identify these elements in Python
regular expression..


Answer: `re.findall` will return all matches:

    
    
    import re
    
    data = """
    t_hat_1
    t_hat_2
    t_hat_3
    name
    s_flower_1
    s_flower_2
    s_flower_3
    s_flower_22
    s_flower_23
    address
    """
    
    flowers_patterns = re.findall('(s_flower_\d+)', data)
    hat_patterns = re.findall('(t_hat_\d+)', data)
    

