두 개의 세미콜론 (:) 사이에 문자열을 분할하고 싶습니다. 즉,자바에서 두 개의 문자 사이에 분할
BOOLEAN : 미스터 커피 - 리콜 : 8a42bb8b36a6b0820136aa5e05dc01b3 : 1346790794980
을 내가
split("[\\:||\\:]");
하지만이 "로
두 개의 세미콜론 (:) 사이에 문자열을 분할하고 싶습니다. 즉,자바에서 두 개의 문자 사이에 분할
BOOLEAN : 미스터 커피 - 리콜 : 8a42bb8b36a6b0820136aa5e05dc01b3 : 1346790794980
을 내가
split("[\\:||\\:]");
하지만이 "로
를 사용하여 분할을 작동하지를 시도하고있다 : "정규식으로. 더 정확하게
:
String splits[] = yourString.split(":");
//splits will contain:
//splits[0] = "BOOLEAN";
//splits[1] = "Mr. Coffee - Recall";
//splits[2] = "8a42bb8b36a6b0820136aa5e05dc01b3";
//splits[3] = "1346790794980";
분할 할 수 있나요 ":"즉 두 번째 출현 문자열 - BOOLEAN : Mr. Coffee - Recall –
당신은 split()
을 사용하여이 코드를 참조 할 수
String s ="BOOLEAN: Mr. Coffee - Recall:8a42bb8b36a6b0820136aa5e05dc01b3:1346790794980";
String temp = new String();
String[] arr = s.split(":");
for(String x : arr){
System.out.println(x);
}
이 :
String m = "BOOLEAN: Mr. Coffee - Recall:8a42bb8b36a6b0820136aa5e05dc01b3:1346790794980";
for (String x : m.split(":"))
System.out.println(x);
반환
BOOLEAN
Mr. Coffee - Recall
8a42bb8b36a6b0820136aa5e05dc01b3
1346790794980
,536,913,632 10
정규식은 맛 :
String yourString = "BOOLEAN: Mr. Coffee - Recall:8a42bb8b36a6b0820136aa5e05dc01b3:1346790794980";
String [] componentStrings = Pattern.compile(":").split(yourString);
for(int i=0;i<componentStrings.length;i++)
{
System.out.println(i + " - " + componentStrings[i]);
}
관련 http://stackoverflow.com/questions/4962176/java-extract-part-of-a-string-between-two-special-characters –