I\'m trying to extract a string from round brackets. Let\'s say, I have John Doe (123456789) and I want to output the string 123456789 only.
John Doe (123456789)
123456789
this works for me :
@Test public void myTest() { String test = "test (mytest)"; Pattern p = Pattern.compile("\\((.*?)\\)"); Matcher m = p.matcher(test); while(m.find()) { assertEquals("mytest", m.group(1)); } }