Okay, Now I am able to parse space which was my previous problem. Now my parser is almost ready but has a defect which I am unable to figure out.
I am able to retrieve Data after segments(see code) and data in between pipes.
What I am not able to get to is a level up and retrieve data which is contained between pipes and seperated by ^.
Eg.
Input String is A|1|2|3^4|
Expected Output
element1 A
element2 1
element3 2
element4.1 3
element4.2 4
However, My current output is coming to be
element1 A
element2 1
element3 2
element4 3^4
I am recieving exception
1 [Ljava.lang.String;@1786e64 with various ids after @
The commented code given below is creating problem.
CODE:
Scanner scanner = new Scanner(System.in);
str=scanner.nextLine();
System.out.println(str);
segments="(A)|(B)|(C)|(D)";
pipe="[\\s+\\|+\\+]";
carat="[\\^+]";
for(i=0;i<token_type1.length;i++)
{
token_type2=token_type1[i].toString().split(pipe);
for(j=0;j<token_type2.length;j++)
{
/*
token_type3=token_type2.toString().split(carat);
for(k=0;k<token_type3.length;k++)
System.out.println("\t"+(k+1)+" "+token_type3[k]);
*/
System.out.println((j+1)+"\t"+token_type2[j]);
}
System.out.println();
}
Please advise.
This will transform your input to your desired output (save the classes in two different files)
and