use first capture group in regex
This commit is contained in:
parent
d90eac3fe6
commit
9f0db28ed8
4 changed files with 12 additions and 11 deletions
|
@ -5,7 +5,6 @@ import subprocess
|
|||
def get(value, regex):
|
||||
output = subprocess.getoutput(value)
|
||||
r = re.search(regex, output)
|
||||
if r:
|
||||
result = r.group('datacenter')
|
||||
return result
|
||||
if r and len(r.groups()) > 0:
|
||||
return r.groups()[0]
|
||||
return None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue