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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