Java 竖线|的转义符 是 "\\|"
如下操作
String str = "1231231 | werewrwe";
如下操作
String str = "1231231 | werewrwe";
String[] b = str.split("\\|");//直接使用str.split("|")是错误的
package com.myTest;
public class splittest {
/**
* @param args
* @date 2013-2-22 下午03:57:22
*/
public static void main(String[] args) {
String str = "1231231 | werewrwe";
//str = str.replace("|", ",");
String[] by = str.split("\\|");
for(int i=0; i<by.length;i++){
System.out.println("字符:"+by[i]);
}
}
}