Trouble Splitting String Using | [pipe] in Java

While developing java application I came across a problem while splitting string in java using pipe | as delimiter. The problem I was getting is that when using below code:


It splits the string on every single character. I wasted my 20 minutes solving this problem.

In the end I found that using double backslash before pipe in regular expression made it work fine.


I thought I should blog about this because if someone else run into this issue can save their 20 minutes which I wasted in finding such a minor issue.

Tags: , , ,

Comments & Responses

Leave a Reply

Your email address will not be published. Required fields are marked *


− 1 = 2

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>