2012-11-01 3 views
1

단어 목록이 있고 토큰 화 후에 필자가 실제로 원하지 않는 목록에 빈 공간이 생깁니다. 제안 제발 ...토큰 화 후 목록의 빈 공백

샘플 문자열

String str = "3) type an \"l\" in the search field (\"bl\")"+ 
"4) startHistorySearch()'s previous result contains [\"blah\", \"baaa\", \"bloop\", \"bzzz\"], Satchel filters this down to [\"blah\", \"bloop\"] to match the new \"bl\" search string"+ 
and so on..... 

여기에 코드 및 출력 조각

String[] splitString = (EXAMPLE_TEST.split("[\\[\\],\\'\" \\(\\)\\{\\}\\*\\.]")); 

nsIAutoCompletResult, , no, , Simple, , , , so, the, QI, fails, , historyResult 

와 나는이 같은보고 어떤 장소에서 출력입니다 .. .

finds, 1, entry, , , blah, , , , search-suggestions, finds, , baaa, , , , bloop, , , , bzzz, , , the, autocompete, menu, shows, these, in, order, with, a, divider, between, , blah, , and, , baaa, , 3, , type, , l, , in, the, search, field, , , bl, , 4, , startHistorySearch, , , s, previous, result, contains, , , blah, , , , baaa, , , , bloop, , , , bzzz, , , , Satchel, filters, this, down, to, , , blah, , , , bloop, , , to, match, the, new, , bl, , search, string5, , nsSearchSuggestions, s, onReadyState, , , change, is, called, with, updated, search, 
+0

다시 반복하여 다듬은 후 길이가 0 인 항목을 제거하십시오. – case1352

답변

0

두 개의 토큰을 분리하지 않으려면 표현식에 +을 추가하기 만하면됩니다. 표현식을 약간 단순화 할 수 있습니다. 문자 클래스에서 모든 문자를 이스케이프 처리 할 필요가 없습니다.

String[] splitString = (EXAMPLE_TEST.split("[\\[\\],'\"(){}*.]+"));