/* package whatever; // don't place package name! */
import java.util.* ;
import java.lang.* ;
import java.util.regex.Matcher ;
import java.util.regex.Pattern ;
import java.io.* ;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
{
String text
= "This_is_a_[sample]_text[notworking]" ; Matcher matcher = Pattern.compile ( "\\ [([a-zA-Z_]+)\\ ]" ) .matcher ( text) ;
int i = 0 ;
while ( matcher.find ( ) ) {
for ( int j = 0 ; j <= matcher.groupCount ( ) ; j++ ) {
System .
out .
println ( "------------------------------------" ) ; System .
out .
println ( "Group " + i
+ ": " + matcher.
group ( j
) ) ; i++;
}
}
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLnV0aWwucmVnZXguTWF0Y2hlcjsKaW1wb3J0IGphdmEudXRpbC5yZWdleC5QYXR0ZXJuOwppbXBvcnQgamF2YS5pby4qOwoKLyogTmFtZSBvZiB0aGUgY2xhc3MgaGFzIHRvIGJlICJNYWluIiBvbmx5IGlmIHRoZSBjbGFzcyBpcyBwdWJsaWMuICovCmNsYXNzIElkZW9uZQp7CglwdWJsaWMgc3RhdGljIHZvaWQgbWFpbiAoU3RyaW5nW10gYXJncykgdGhyb3dzIGphdmEubGFuZy5FeGNlcHRpb24KCXsKCQlTdHJpbmcgdGV4dCA9ICJUaGlzX2lzX2FfW3NhbXBsZV1fdGV4dFtub3R3b3JraW5nXSI7CgkJTWF0Y2hlciBtYXRjaGVyID0gUGF0dGVybi5jb21waWxlKCJcXFsoW2EtekEtWl9dKylcXF0iKS5tYXRjaGVyKHRleHQpOyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKCQlpbnQgaSA9IDA7CgkJd2hpbGUgKG1hdGNoZXIuZmluZCgpKSB7CgkJICAgIGZvciAoaW50IGogPSAwOyBqIDw9IG1hdGNoZXIuZ3JvdXBDb3VudCgpOyBqKyspIHsKCQkJICAgIFN5c3RlbS5vdXQucHJpbnRsbigiLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tIik7CgkJCSAgICBTeXN0ZW0ub3V0LnByaW50bG4oIkdyb3VwICIgKyBpICsgIjogIiArIG1hdGNoZXIuZ3JvdXAoaikpOwoJCQkgICAgaSsrOwoJCQl9CgkJfQoJfQp9