我想分割这个字符串:
String[] parts[] = line.split("|");
进入(" 04/25/17"," 13:00"," 0号线和#34;);
我试过了
String[] parts[] = line.split("\\|");
我有(0,4,/,2,5,/,7,1,3,:,0,0,L,i,n,e,0)
然后我试了module.exports = {
attributes: {
firstName: {
type: 'string'
},
lastName: {
type: 'string'
},
email: {
type: 'string',
required: true,
unique: true
},
password: {
type: 'string',
required: true
},
authTokens: {
collection: 'authToken',
via: 'owner'
}
}
}
我得到了相同的结果
请帮忙!
答案 0 :(得分:-1)
如果你的字符串都具有相同的长度,你可以使用substring():
String line = "04/25/17|13:00|Line 0";
String part1 = line.substring(0,7);
String part2 = line.substring(9,13);
String part3 = line.substring(15,line.length());