If you are writing a parser you can do without a regex. From the educational point of view, in PHP PCRE regex, you can use recursion and subroutine calls.
Have a look at
(?<name>[^\s()]+)(\((?<body>(?>[^()]++|(?2))*)\))
See the regex demo
Group "name" will contain the function name and "body" group will hold what is inside the matching parentheses.
Note you need to add both ( and ) to the negated character class (?<funcion>[^\s()]+) because in case you have sample(decimal(3*3)) this group will grab the substring up to the ) (sample(decimal). Thus, you need to exclude both ( and ).
The (\((?<body>(?>[^()]++|(?2))*)\)) part is a capture group (with ID=2) that can be recursed (i.e. "repeated", "expanded" many times) with a subroutine call (?2).
It matches
\( - an open round bracket
(?<body>(?>[^()]++|(?2))*) - Group "body" that matches zero or more sequences of:
[^()]++ - 1+ characters other than ( and ) or
(?2) - the whole \((?<body>(?>[^()]++|(?2))*)\) subpattern
\) - a closing parenthesis
The (?2) subroutine call necessity (as compared to recursion with (?R)) is dictated by the fact that we need to repeat/recurse a part of the pattern.
Since Group 2 is a "technical" capture group, it might be a good idea to use named capture groups for those parts we want to really use.
([^\s)]+)(\(((?>[^()]++|(?1))*)\))- but if you are making a parser, I guess you need no regex.preg_match('/([^\s\)]+)\((.+)\)/', 'sample( decimal( 5*5 ) ) toString(euros)', $matches)(pushing them onto a stack along with whatever content comes after them. When you hit the first)you can pop the contents, and this is a function argument or set of arguments.