I am trying to extract the values between the brackets (and )before I managed to check if the value is there. Help me extract it, please.
(
)
Pattern pattern; pattern = Pattern.compile("\\b(.*\\b)"); Matcher matcher = pattern.matcher(node.toString()); if (matcher.find()){ System.out.println();// here I need to print value that I find between brackets }
Choose parentheses in your regex:
Pattern pattern = Pattern.compile("\\((.*?)\\)");
Then you can do:
Matcher matcher = pattern.matcher(node.toString()); if (matcher.find()){ System.out.println( matcher.group(1) ); }