Reputation: 11251
I attempt to extract values between brackets (
and )
, before I was managed only to check presence of value. Help me to 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
}
Upvotes: 3
Views: 1120
Reputation: 786031
Escape the brackets 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) );
}
Upvotes: 7