嗨,我試圖分裂這個字符串了(它很長):Java的正則表達式嘗試了分割字符串
Library Catalogue Log off | Borrower record | Course Reading | Collections | A-Z E-Journal list | ILL Request | Help Browse | Search | Results List | Previous Searches | My e-Shelf | Self-Issue | Feedback Selected records: View Selected | Save/Mail | Create Subset | Add to My e-Shelf | Whole set: Select All | Deselect | Rank | Refine | Filter Records 1 - 15 of 101005 (maximum display and sort is 2500 records) 1 Drower, E. S. (Ethel Stefana), Lady, b. 1879. Lady E.S. Drower’s scholarly correspondence : an intrepid English autodidact in Iraq / edited by 2012. BK Book University Library(1/ 0) 2 Kowalski, Robin M. Cyberbullying : bullying in the digital age / Robin M. Kowalski, Susan P. Limber, Patricia W. Ag 2012. BK Book University Library(1/ 0) ... 15 Ambrose, Gavin. Approach and language [electronic resource] / Gavin Ambrose, Nigel Aono-Billson. 2011. BK Book
所以,我要麼得到回:
1 Drower, E. S. (Ethel Stefana), Lady, b. 1879. Lady E.S. Drower’s scholarly correspondence : an intrepid English autodidact in Iraq/edited by 2012. BK Book University Library(1/ 0)
// Or
1 Drower, E. S. (Ethel Stefana), Lady, b. 1879. Lady E.S. Drower’s scholarly correspondence : an intrepid English autodidact in Iraq
這只是一個例子和1 Drower,ES ...不會是靜態的。雖然每次輸入都會有所不同(1和2之間的細節),但字符串的總體佈局總是相同的。
我:
String top = ".* (.*)";
String bottom = "\(\d/ \d\)\W*";
Pattern p = Pattern.compile(top); //+bottom
Matcher matcher = p.matcher(td); //td is the input String
String items = matcher.group();
System.out.println(items);
當我與top
運行它,它的目的是去除所有的頭,但所有我得到的回覆是No match found
。 bottom
是我嘗試拆分字符串的其餘部分。
如果需要的話,我可以發佈所有輸入到15號。我需要的是分割輸入字符串,以便我可以處理15個結果中的每個個體。
感謝您的幫助!
以某種方式是的。但事情是,輸入不是靜態的,意志會根據搜索結果而改變。對不起,我應該提到這一點。但是,輸入字符串的佈局不會更改。數字1只是第一個搜索結果,它會達到15個結果。如果需要,我可以將所有輸入發佈到15號。 – Tbuermann 2012-03-14 20:14:34
所以你需要分割所有的搜索結果,據我所知? – JMelnik 2012-03-14 20:25:18
是的,這是正確的。例如:[1 Drower,E. S. ..]應該是一個String和[2 Kowalski,Robin M. ..]直到[15 Ambrose,Gavin。 ..]應該是下一個字符串。該輸入根據搜索結果而變化。但輸入字符串的佈局將始終相同。所以1,2,3 .. 15.除非有少於15個結果,否則總會在那裏 – Tbuermann 2012-03-14 20:28:18