Question: 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.

Answer: 
Use method `Sting.split()`. Think about all your delimiters and put they all as an argument to split. Be aware that split works with regex, so special characters like `|` must be escaped. For example line:

`String[] tokens = str.split("[\\s+\\|]");`

should create expected tokens from your input.
Scanner() by default has space as delimeter. So if you do scanner.next() again then you will get the remaining input part, '4'.

You can set your own delimeter by using `usedelimeter(String pattern)` api of Scanner class.