/*
Online Java - IDE, Code Editor, Compiler

Online Java is a quick and easy tool that helps you to build, compile, test your programs online.
*/

import java.util.*;

public class Main
{
    static boolean nextDelimiter=false;
    static String []delimiters = new String[]{"//", "/", ":", ","};
    static int num=0;
    
    static String temp;
    static String beforeCurrentTokenizer;
    
    
    public static void reverseWords(String text, int num, String beforeCurrentTokenizer)
    {
        do
        {
            System.out.println("valu num: " + num);
            
       
        
        StringBuilder sb = new StringBuilder();
        StringJoiner sj = new StringJoiner(" ");
        
        StringTokenizer st = new StringTokenizer(text, delimiters[num]);
        
        while(st.hasMoreTokens())
        {
            beforeCurrentTokenizer = temp;
            temp=st.nextToken();
            //There would need be an element of recursion here
            //so that it can check for other test conditions
            System.out.println(temp);
            
            if (temp!=beforeCurrentTokenizer && num!=0)
            {
                //this point it has to start delimiters again in event another delimiter appears
                num=0;
                nextDelimiter=true;
            }
            
            //lengthTokensProcessed = 
            
            //sb.append()
            
            //it would need pass this again for analysis and also original text.
            //not entirely sure how it would know where to proceed from.
            //only technique is keeping a running total of content appended in a stringbuilder.
            
            if (!nextDelimiter)
            {
                num++;
                nextDelimiter=false;
            }
            
            reverseWords(temp, num, beforeCurrentTokenizer);
            
        }
        while (!st.hasMoreTokens())
        {
            System.out.println("end");
            break;
        }
        
        }while(num<(delimiters.length-1));
        
    }
    
    public static void main(String[] args) {
        System.out.println("Welcome to Online IDE!! Happy Coding :)");
        
        String text="hello:world/here";
        reverseWords(text,num, beforeCurrentTokenizer);
    }
}