Created
October 28, 2011 00:00
-
-
Save margusmartsepp/1321251 to your computer and use it in GitHub Desktop.
Method that finds possible function calls in a script string.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 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