import java.util.regex.Matcher;
import java.util.regex.Pattern;
class TesteRegex {
private static final Pattern ABC = Pattern.compile("A+B+C+");
public static void main
(String[] args
) { String texto
= "123 456 7890 ABx AAACCC AABBCC hjkhkk ABBBBCCC djsdhj ABC kdjk."; Matcher m = ABC.matcher(texto);
while (m.find()) {
System.
out.
println("Achou nas posições " + m.
start() + "-" + m.
end() + ": " + texto.substring(m.start(), m.end()));
}
}
}
aW1wb3J0IGphdmEudXRpbC5yZWdleC5NYXRjaGVyOwppbXBvcnQgamF2YS51dGlsLnJlZ2V4LlBhdHRlcm47CgpjbGFzcyBUZXN0ZVJlZ2V4IHsKCiAgICBwcml2YXRlIHN0YXRpYyBmaW5hbCBQYXR0ZXJuIEFCQyA9IFBhdHRlcm4uY29tcGlsZSgiQStCK0MrIik7CgogICAgcHVibGljIHN0YXRpYyB2b2lkIG1haW4oU3RyaW5nW10gYXJncykgewogICAgICAgIFN0cmluZyB0ZXh0byA9ICIxMjMgNDU2IDc4OTAgQUJ4IEFBQUNDQyBBQUJCQ0MgaGpraGtrIEFCQkJCQ0NDIGRqc2RoaiBBQkMga2Rqay4iOwogICAgICAgIE1hdGNoZXIgbSA9IEFCQy5tYXRjaGVyKHRleHRvKTsKICAgICAgICB3aGlsZSAobS5maW5kKCkpIHsKICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCJBY2hvdSBuYXMgcG9zacOnw7VlcyAiICsgbS5zdGFydCgpICsgIi0iICsgbS5lbmQoKSArICI6ICIKICAgICAgICAgICAgICAgICAgICArIHRleHRvLnN1YnN0cmluZyhtLnN0YXJ0KCksIG0uZW5kKCkpKTsKICAgICAgICB9CiAgICB9Cn0=