/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
{
final String regex
= "[#]\\w*\\d*\\W\\s*"; final String string
= "oi tudo bem como vai #01?";
final Pattern pattern = Pattern.compile(regex);
final Matcher matcher = pattern.matcher(string);
while (matcher.find()) {
System.
out.
println("Full match: " + matcher.
group(0)); for (int i = 1; i <= matcher.groupCount(); i++) {
System.
out.
println("Group " + i
+ ": " + matcher.
group(i
)); }
}
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CmltcG9ydCBqYXZhLnV0aWwucmVnZXguTWF0Y2hlcjsKaW1wb3J0IGphdmEudXRpbC5yZWdleC5QYXR0ZXJuOwoKLyogTmFtZSBvZiB0aGUgY2xhc3MgaGFzIHRvIGJlICJNYWluIiBvbmx5IGlmIHRoZSBjbGFzcyBpcyBwdWJsaWMuICovCmNsYXNzIElkZW9uZQp7CglwdWJsaWMgc3RhdGljIHZvaWQgbWFpbiAoU3RyaW5nW10gYXJncykgdGhyb3dzIGphdmEubGFuZy5FeGNlcHRpb24KCXsKCWZpbmFsIFN0cmluZyByZWdleCA9ICJbI11cXHcqXFxkKlxcV1xccyoiOwpmaW5hbCBTdHJpbmcgc3RyaW5nID0gIm9pIHR1ZG8gYmVtIGNvbW8gdmFpICMwMT8iOwoKZmluYWwgUGF0dGVybiBwYXR0ZXJuID0gUGF0dGVybi5jb21waWxlKHJlZ2V4KTsKZmluYWwgTWF0Y2hlciBtYXRjaGVyID0gcGF0dGVybi5tYXRjaGVyKHN0cmluZyk7Cgp3aGlsZSAobWF0Y2hlci5maW5kKCkpIHsKICAgIFN5c3RlbS5vdXQucHJpbnRsbigiRnVsbCBtYXRjaDogIiArIG1hdGNoZXIuZ3JvdXAoMCkpOwogICAgZm9yIChpbnQgaSA9IDE7IGkgPD0gbWF0Y2hlci5ncm91cENvdW50KCk7IGkrKykgewogICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigiR3JvdXAgIiArIGkgKyAiOiAiICsgbWF0Y2hlci5ncm91cChpKSk7CiAgICB9Cn0KCX0KfQ==