| Author |
String Split problem
|
Andy Holm
Ranch Hand
Joined: Jul 03, 2008
Posts: 86
|
|
I have fields that look like this: "M|F". I want to split that String on the "|". However, it doesn't seem to work when I run the following code: The result I get is every character (M, |, and F) is in its own array index. What am I doing wrong?
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16695
|
|
The "|" has special meaning in a regex -- it is a OR operation for search patterns. If you actually want the literal "|", then you need to escape it as "\\|". Henry
|
Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
|
 |
 |
|
|
subject: String Split problem
|
|
|