Python regular expression search vs match
Question: I'm trying to use a python regular expression to match 'BrahuiHan' or
'BrahuiYourba'

    
    
    >> re.search(r'((Brahui|Han|Yoruba)+\d+)', '10xBrahuiHan50_10xBrahuiYoruba50n4').groups()
    
    ('BrahuiHan50', 'Han')
    

this only returns one group, the first one, I thought it should return the
second one too. i.e BrahuiYoruba


Answer: If you want to capture all occurrences of a pattern, you need to use
[`re.findall`](https://docs.python.org/2/library/re.html#re.findall):

    
    
    >>> import re
    >>> re.findall(r'((Brahui|Han|Yoruba)+\d+)', '10xBrahuiHan50_10xBrahuiYoruba50n4')
    [('BrahuiHan50', 'Han'), ('BrahuiYoruba50', 'Yoruba')]
    >>>
    

`re.search` will only capture the first occurrence.

