java split问题 String str = "20090901|+|029275|+|0|+|620|+||+||+||+|6226661400538058|+||+|20090831";要求按"|+|"分隔;str.split(regex);regex应该是什么呢?试了很多遍,都没有成功,请高手赐教! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 | +都是正则的特殊字符 需要 转义 /** * @param args */ public static void main(String[] args) { String str = "20090901|+|029275|+|0|+|620|+||+||+||+|6226661400538058|+||+|20090831"; String[] temp = str.split("\\|\\+\\|"); for (int i = 0; i < temp.length; i++) { System.out.println(temp[i]); } } String str = "20090901|+|029275|+|0|+|620|+||+||+||+|6226661400538058|+||+|20090831"; String[] temp = str.split("\\|\\+\\|"); for (int i = 0; i < temp.length; i++) { if ("".equals(temp[i])) { return; } System.out.println(temp[i]); } } 是 continue去掉空字符,呵呵 return是对的,对不起。。 /** * @param args */ public static void main(String[] args) { String str = "20090901|+|029275|+|0|+|620|+||+||+||+|6226661400538058|+||+|20090831"; String[] temp = str.split("\\|\\+\\|"); for (int i = 0; i < temp.length; i++) { if ("".equals(temp[i])) { continue; } System.out.println(temp[i]); } } 关于ListIterator的问题 apache commons-lang.jar源码问题 偶是菜鸟,想知道怎样用Applet在服务器端生成数据. jar在hpux上压缩对文件大小有限制吗? 如何在不同窗体间传递数据 在java事务处理中,commit之后如何保存ResultSet *****************请问有谁用过RMI的HTTP隧道机制?************** Java播放MP3的代码 我想学java 又怕太难 对自己没有信心..... 有关编译时的几个简单问题!谢谢! 新手请问大家eclipse程序报错问题~~ 是谁把我的数组给更新了???
* @param args
*/
public static void main(String[] args)
{
String str = "20090901|+|029275|+|0|+|620|+||+||+||+|6226661400538058|+||+|20090831"; String[] temp = str.split("\\|\\+\\|");
for (int i = 0; i < temp.length; i++)
{
System.out.println(temp[i]);
} }
String str = "20090901|+|029275|+|0|+|620|+||+||+||+|6226661400538058|+||+|20090831"; String[] temp = str.split("\\|\\+\\|");
for (int i = 0; i < temp.length; i++)
{
if ("".equals(temp[i]))
{
return;
}
System.out.println(temp[i]);
} }
* @param args
*/
public static void main(String[] args)
{
String str = "20090901|+|029275|+|0|+|620|+||+||+||+|6226661400538058|+||+|20090831"; String[] temp = str.split("\\|\\+\\|");
for (int i = 0; i < temp.length; i++)
{
if ("".equals(temp[i]))
{
continue;
}
System.out.println(temp[i]);
} }