I want to get the first match of a regex.
In this case, I got a list:
text = \'aa33bbb44\' re.findall(\'\\d+\',text)
I'd go with:
r = re.search("\d+", ch) result = return r.group(0) if r else ""
re.search only looks for the first match in the string anyway, so I think it makes your intent slightly more clear than using findall.
re.search
findall