fork download
  1. import java.util.*;
  2.  
  3. class Program {
  4. public static void main (String[] args) {
  5. String texto = "(:TEXTOQUALQUER NADA DO FOI :TEXTOQQDENOVO SERÁ DE NOVO :TEXTOQQMAIS DO JEITO QUE UM DIA :TEXTO3343)";
  6. List<String> textos = new ArrayList<String>();
  7. while (texto.length() > 0) {
  8. texto = texto.substring(texto.indexOf(":") + 1);
  9. int posicaoParentese = texto.indexOf(")");
  10. int posicaoEspaco = texto.indexOf(" ");
  11. int posicaoFinal = Math.min((posicaoParentese == -1 ? Integer.MAX_VALUE : posicaoParentese), (posicaoEspaco == -1 ? Integer.MAX_VALUE : posicaoEspaco));
  12. textos.add(texto.substring(0, posicaoFinal));
  13. texto = texto.substring(posicaoFinal + 1);
  14. }
  15. for (String item : textos) System.out.println(item);
  16. }
  17. }
  18.  
  19. //https://pt.stackoverflow.com/q/43717/101
Success #stdin #stdout 0.05s 2184192KB
stdin
Standard input is empty
stdout
TEXTOQUALQUER
TEXTOQQDENOVO
TEXTOQQMAIS
TEXTO3343