String inpt= "object[attr1=val1 attr2=val2 attr3=val3]";
Pattern pathPattern = Pattern.compile("(\\[(/?[^\\>]+)\\])");
Matcher matcher = pathPattern.matcher(inpt);
while(matcher.find()){
pathPattern = Pattern.compile("\\w+");
Matcher m2 = pathPattern.matcher(matcher.group());
while(m2.find()){
System.out.println(m2.group());
}
}