def find_substring(string, pattern1, pattern2=None):
 if (not pattern1):
  logging.debug('pattern1: get empty string.')
  return None
 pattern = pattern1
 if pattern2:
  pattern += ('|%s' % pattern2)
 ret = re.findall(pattern, string)
 if (not ret):
  logging.debug('Could not find matched string with pattern: %s', pattern)
  return None
 return ret[0]

def find_substring ( string , pattern1 , pattern2 = None ) : if ( not pattern1 ) : logging . debug ( 'pattern1: get empty string.' ) return None pattern = pattern1 if pattern2 : pattern += ( '|%s' % pattern2 ) ret = re . findall ( pattern , string ) if ( not ret ) : logging . debug ( 'Could not find matched string with pattern: %s' , pattern ) return None return ret [ 0 ]
return the match of pattern1 in string .