Вы можете проверить, какая группа соответствует:
Pattern p = Pattern.compile("(i.*d.*n.*t.*)|(p.*r.*o.*f.*)|(u.*s.*r.*)");
Matcher m = p.matcher("profile");
m.find();
for (int i = 1; i <= m.groupCount(); i++) {
System.out.println(i + ": " + m.group(i));
}
Будет ли выводиться:
1: null
2: profile
3: null
Поскольку вторая строка не равна нулю, (p.*r.*o.*f.*)
соответствует строке.