I am using this function:
public static String remove_parenthesis(String input_string, String parenthesis_symbol){ // removing parenthesis and everything inside them, works for (),[] and {} if(parenthesis_symbol.contains("[]")){ return input_string.replaceAll("\\s*\\[[^\\]]*\\]\\s*", " "); }else if(parenthesis_symbol.contains("{}")){ return input_string.replaceAll("\\s*\\{[^\\}]*\\}\\s*", " "); }else{ return input_string.replaceAll("\\s*\\([^\\)]*\\)\\s*", " "); } }
You can call it like this:
remove_parenthesis(g, "[]"); remove_parenthesis(g, "{}"); remove_parenthesis(g, "()");
xyshio
source share