import java.util.*;
class Program {
public static void main
(String[] args
) { String texto
= "(:TEXTOQUALQUER NADA DO FOI :TEXTOQQDENOVO SERÁ DE NOVO :TEXTOQQMAIS DO JEITO QUE UM DIA :TEXTO3343)"; List<String> textos = new ArrayList<String>();
while (texto.length() > 0) {
texto = texto.substring(texto.indexOf(":") + 1);
int posicaoParentese = texto.indexOf(")");
int posicaoEspaco = texto.indexOf(" ");
int posicaoFinal
= Math.
min((posicaoParentese
== -1 ? Integer.
MAX_VALUE : posicaoParentese
),
(posicaoEspaco
== -1 ? Integer.
MAX_VALUE : posicaoEspaco
)); textos.add(texto.substring(0, posicaoFinal));
texto = texto.substring(posicaoFinal + 1);
}
}
}
//https://pt.stackoverflow.com/q/43717/101
aW1wb3J0IGphdmEudXRpbC4qOwoKY2xhc3MgUHJvZ3JhbSB7CglwdWJsaWMgc3RhdGljIHZvaWQgbWFpbiAoU3RyaW5nW10gYXJncykgewogICAgICAgIFN0cmluZyB0ZXh0byA9ICIoOlRFWFRPUVVBTFFVRVIgTkFEQSBETyBGT0kgOlRFWFRPUVFERU5PVk8gU0VSw4EgREUgTk9WTyA6VEVYVE9RUU1BSVMgRE8gSkVJVE8gUVVFIFVNIERJQSA6VEVYVE8zMzQzKSI7CiAgICAgICAgTGlzdDxTdHJpbmc+IHRleHRvcyA9IG5ldyBBcnJheUxpc3Q8U3RyaW5nPigpOwogICAgICAgIHdoaWxlICh0ZXh0by5sZW5ndGgoKSA+IDApIHsKICAgICAgICAJdGV4dG8gPSB0ZXh0by5zdWJzdHJpbmcodGV4dG8uaW5kZXhPZigiOiIpICsgMSk7CiAgICAgICAgCWludCBwb3NpY2FvUGFyZW50ZXNlID0gdGV4dG8uaW5kZXhPZigiKSIpOwogICAgICAgIAlpbnQgcG9zaWNhb0VzcGFjbyA9IHRleHRvLmluZGV4T2YoIiAiKTsKICAgICAgICAJaW50IHBvc2ljYW9GaW5hbCA9IE1hdGgubWluKChwb3NpY2FvUGFyZW50ZXNlID09IC0xID8gSW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