Home Java String.split() and the | (pipe) character
Post
Cancel

Java String.split() and the | (pipe) character

I came across this issue today and someone else already blogged about it: http://hoskinator.blogspot.com/2006/11/trouble-using-pipe-with-stringsplit.html. Some of the comments are really good!

The pipe character is not mentioned in the Pattern javadoc.

Basically, just escape the pipe character with double backslashes like so "\\|" and you're set.

This post merely provides redundancy in case the above link goes extinct...
This post is licensed under CC BY 4.0 by the author.

Vim Tip of the Day

The Tao of Programming