public static void main(String[] args) { String content = "(hello)"; String regex = "(?<=\\().*(?=\\))"; Pattern p = Pattern.compile(regex); Matcher m = p.matcher(content); while (m.find()) { System.out.println(m.group()); } } public static void main(String[] args) { String content = "(hello)"; String regex = "[^()]+"; Pattern p = Pattern.compile(regex); Matcher m = p.matcher(content); while (m.find()) { System.out.println(m.group()); } }