FULL PRODUCT VERSION :
Netbeans 4.0 internal enviroment
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP Professional
Versione 2002
Service Pack 1
A DESCRIPTION OF THE PROBLEM :
The following java code:
str.split("|");
str.split("\u007c");
they both split the str string in a wrong way.
Instead of splitting the str for each "|" char,
the str is splitted in strings of one char each.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run this piece of code:
String str = "first|second";
String[] strArray = str.split("|");
for(int ii=0;ii<strArray.length;ii++)
System.out.println(strArray[ii]);
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Output:
first
second
ACTUAL -
Output:
f
i
r
s
t
|
s
e
c
o
n
d
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
String str = "first|second";
String[] strArray = str.split("|");
for(int ii=0;ii<strArray.length;ii++)
System.out.println(strArray[ii]);
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
if the str string does not contain the ";"
you can substitute the str.split("|");
with str.replace('|', ';').split(";");
###@###.### 2005-04-12 08:54:27 GMT
Netbeans 4.0 internal enviroment
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP Professional
Versione 2002
Service Pack 1
A DESCRIPTION OF THE PROBLEM :
The following java code:
str.split("|");
str.split("\u007c");
they both split the str string in a wrong way.
Instead of splitting the str for each "|" char,
the str is splitted in strings of one char each.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run this piece of code:
String str = "first|second";
String[] strArray = str.split("|");
for(int ii=0;ii<strArray.length;ii++)
System.out.println(strArray[ii]);
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Output:
first
second
ACTUAL -
Output:
f
i
r
s
t
|
s
e
c
o
n
d
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
String str = "first|second";
String[] strArray = str.split("|");
for(int ii=0;ii<strArray.length;ii++)
System.out.println(strArray[ii]);
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
if the str string does not contain the ";"
you can substitute the str.split("|");
with str.replace('|', ';').split(";");
###@###.### 2005-04-12 08:54:27 GMT
- duplicates
-
JDK-5061438 String.split produces unexpected output when '|' delimiter is used
-
- Closed
-
- relates to
-
JDK-6254566 (spec str) String.split() should explain string quoting for literal instead of regex behavior
-
- Open
-