I want to get the first match of a regex.
In this case, I got a list:
text = \'aa33bbb44\' re.findall(\'\\d+\',text)
You can do:
x = re.findall('\d+', text) result = x[0] if len(x) > 0 else ''
Note that your question isn't exactly related to regex. Rather, how do you safely find an element from an array, if it has none.