There is a known \"pattern\" to get the captured group value or an empty string if no match:
match = re.search(\'regex\', \'text\')
if match:
value = mat
You can do it as:
value = re.search('regex', 'text').group(1) if re.search('regex', 'text') else ''
Although it's not terribly efficient considering the fact that you run the regex twice.
Or to run it only once as @Kevin suggested:
value = (lambda match: match.group(1) if match else '')(re.search(regex,text))