I have an expression Nvl(cost,Sum(cost1)) i need to remove string before paranthesis i.e NVl and Sum in this case
String functions=externalFormat.replaceAll("\\([^\\(]*\\)", "");
Input Nvl(cost,Sum(Cost1) Output cost,cost1
If you can't use capture groups (ie, if you CAN use capture groups, (\w*?)\( will capture the text you need to replace in the first group)
You could use a positive look-ahead to only capture word characters (letter or number) that appear before an open bracket:
\w*(?=\()
You could even add optional white space characters in case of things like: Nvl1 (cost,Sum (cost1)) by including them before the look-ahead: -
\w*\s*(?=\()
Hope this helps solve your problem.
\w+\(|\)and replace with empty string.