def ExpandXcodeVariables(string, expansions):
 matches = _xcode_variable_re.findall(string)
 if (matches == None):
  return string
 matches.reverse()
 for match in matches:
  (to_replace, variable) = match
  if (not (variable in expansions)):
   continue
  replacement = expansions[variable]
  string = re.sub(re.escape(to_replace), replacement, string)
 return string

def ExpandXcodeVariables ( string , expansions ) : matches = _xcode_variable_re . findall ( string ) if ( matches == None ) : return string matches . reverse ( ) for match in matches : ( to_replace , variable ) = match if ( not ( variable in expansions ) ) : continue replacement = expansions [ variable ] string = re . sub ( re . escape ( to_replace ) , replacement , string ) return string
expands xcode-style $ in string per the expansions dict .