Thursday, June 02, 2011

java regex pipe problem

I was trying to split a string to an array. and the special character was | (pipe).

String[] incomings=income.split("|");


and here is the out for income="abcd|efg"


{"a","b","c","d","e","f","g"}


then I understand that this pipe char turns this issue an regex one and doing some strange stuff :) after some research I found the solution. here is the solution for regex pipe


incomings=income.split(Pattern.quote("|"));


this makes the output for same situation like this:

{"abcd","efg"}


lovely

No comments:

sony xperia 10 VI did not like the case

After iphone 16 I wanted to test an android and looks like sony xperia 10 VI is nice, which is 6.1 inches, but it was narrow and longer than...