In a particular example, I want to extract function calls in a string input (ruby script), to do some statistics (in java). For an example input of:
Math.sqrt(2-Math.hypot((3),4))-factorial(5)
I want to get a list of possible
functions used (verification does not need to be 100% accurate, and it can include some extra faulty guesses) :
{ Math.sqrt, Math.hypot, factorial }
List does not have to be case sensitive, but it should include function class path if it exists.
I tried naively simplistic ".*\\((.*)\\)"
, but I could not get it to work. It seems, that I need to use lookaheads or backreference, but I'm a bit stumped. My question is, can I even do this?