嗨,我试图分裂这个字符串了(它很长):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