private String applyReplacementFunction(String function, String replacement, Map<String, Map<String, String>> replacementsMap) {
    if (function != null) {
      Matcher matcher = PATTERN_FUNCTION.matcher(function);

      if (matcher.matches()) {
        String name = matcher.group(1);

        if (name != null) {
          Function f = FUNCTIONS.get(name);

          if (f != null) {
            String args = matcher.group(2);
            String[] argsList = args.split("(?<!\\\\),");

            // Remove escape character from '\,'
            for (int i = 0; i < argsList.length; i++) {
              argsList[i] = argsList[i].trim().replace("\\,", ",");
            }

            return f.perform(argsList, replacement, replacementsMap);
          }
        }
      }
    }

    return replacement;
  }
Applies the specified replacement function to the supplied data.
<p/>
The function must be in the following format:
<code>
name(arg1,arg2,arg3...)
</code>
<p/>
Commas in arguments should be escaped with a '/'.

@param function        the name and arguments of the function
@param replacement     the data to use in the function
@param replacementsMap a Map of data used to perform variable replacements, if needed
@return a new string generated by applying the function
ambari-server/src/main/java/org/apache/ambari/server/state/kerberos/VariableReplacementHelper.java