Skip to content

Instantly share code, notes, and snippets.

@margusmartsepp
Created October 28, 2011 00:01
Show Gist options
  • Select an option

  • Save margusmartsepp/1321253 to your computer and use it in GitHub Desktop.

Select an option

Save margusmartsepp/1321253 to your computer and use it in GitHub Desktop.
Method that finds possible function calls in a script string.
/**
* Method that finds possible function calls in a script string.
*
* @param eval
* script string
* @return Collection of function calls
* @author Margus Martsepp
*/
public static Collection<String> getFunctionCalls(String eval) {
ArrayList<String> result = new ArrayList<String>();
try {
Pattern r = Pattern.compile("(?:\\w+\\.)?\\w+(?=\\()");
Matcher m = r.matcher(eval);
while (m.find())
result.add(eval.substring(m.start(), m.end()));
} catch (Exception e) {
// Suppress idiotic notifications, ex. eval = null.
System.err.println(e.getStackTrace().toString());
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment