Я хочу, чтобы извлечь ссылки из текста, начиная с «д = HTTP» и перед «& усилителем», то есть я хочу, чтобы получить текст между этими двумя, и моим выходом должен быть какдобывающие ссылки из текста
http://ibnlive.in.com/news/noidas-nithari-killings-sc-stays-execution-of-convict-surinder-koli-for-a-week/497153-3-242.html
который статистика от «HTTP» и заканчивается перед «& усилителя» То, что я пытался это
Pattern p = Pattern.compile(".*?q=(http:.*?)&");
Matcher m = p.matcher(content);
String pageid = "";
if (m.find())
{
pageid = m.group(1);
}
System.out.println(pageid);
ниже содержание моего файла text.html ...
q=http://www.thehindu.com/news/national/supreme-court-execution-of-nithari-killer-surinder-koli/article6390120.ece&sa=U&ei=qTUNVOalHMe2uATE_YGQDw&ved=0CBQQpwI&usg=AFQjCNFDcbVK87iUjDwI21jbIZUg0aU8gQ"><img class="th" height="100" src="http://t1.gstatic.com/images?q=tbn:ANd9GcSUUkUw1JxXWJQj2SCQr3XxoIcY5OpWLzDgHIqvLzDgmrfntT9nRi99Lvuuheh05L50VDbs-pY" width="100" border="1"><br></a><span class="_pJb _yhd">The Hindu</span></td><td valign="top"><div style="margin-top:5px"><a href="/url?q=http://ibnlive.in.com/news/noidas-nithari-killings-sc-stays-execution-of-convict-surinder-koli-for-a-week/497153-3-242.html&sa=U&ei=qTUNVOalHMe2uATE_YGQDw&ved=0CBYQqQIwAA&usg=AFQjCNFPPZfQCJQH3vFo1I9Avu-ug8EcSg">Noida's <b>Nithari killings</b>: SC stays execution of convict Surinder Koli for a week</a><div style="padding-top:2px"><cite>IBNLive</cite><span class="f"> - <span class="nobr">1 hour ago</span><span class="nobr"></span></span></div><div class="j" style="margin-top:1px;margin-bottom:4px"><span class="st">New Delhi: The Supreme Court has stayed the execution of Noida's <b>Nithari</b> <b>killings</b> convict Surinder Koli for one week. An official of the apex ...</span></div></div><div style="margin-top:4px"><a href="/url?q=http://www.firstpost.com/india/sc-defers-nithari-killings-convict-surendra-kolis-hanging-week-1701475.html&sa=U&ei=qTUNVOalHMe2uATE_YGQDw&ved=0CBgQqQIwAQ&usg=AFQjCNGsfNy0HC_rfyMfPSSpU66FmUydIw">SC defers <b>Nithari killings</b> convict Surendra Koli's hanging by a week</a><div style="padding-top:2px"><cite>Firstpost</cite><span class="f"> - <span class="nobr">1 hour ago</span><span class="nobr"></span></span></div></div><div style="margin-top:4px"><a href="/url?q=http://www.hindustantimes.com/india-news/nithari-killer-surinder-koli-to-be-hanged-on-sept-12-jail-authorities/article1-1260116.aspx&sa=U&ei=qTUNVOalHMe2uATE_YGQDw&ved=0CBoQqQIwAg&usg=AFQjCNEjeDnCXSwCCWtXO87tIhj6athCCA"><b>Nithari</b> case: Surinder Koli to be hanged on Sept 12</a><div style="padding-top:2px"><cite>Hindustan Times</cite><span class="f"> - <span class="nobr">3 days ago</span><span class="nobr"></span></span></div></div></td></tr></table></div></li><li class="g"><h3 class="r"><a href="/url?q=http://en.wikipedia.org/wiki/Noida_serial_murders&sa=U&ei=qTUNVOalHMe2uATE_YGQDw&ved=0CBwQFjAD&usg=AFQjCNGATKIaCWR1Hl-yqEqXcb1XnXKu9g">Noida serial <b>murders</b> - Wikipedia, the free encyclopedia</a></h3><div class="s"><div class="kv" style="margin-bottom:2px"><cite>en.wikipedia.org/wiki/Noida_serial_<b>murders</b></cite><div class="_nBb"><div style="display:inline" onclick="google.sham(this);" aria-expanded="false" aria-haspopup="true" tabindex="0" data-ved="0CB0Q7B0wAw"><span class="_O0"></span></div><div style="display:none" class="am-dropdown-menu" role="menu" tabindex="-1"><ul><li class="_Ykb"><a class="_Zkb" href="/url?q=http://webcache.googleusercontent.com/search%3Fhl%3Den-IN%26q%3Dcache:ITALXEhw0j8J:http://en.wikipedia.org/wiki/Noida_serial_murders%252Bnithari%2Bkillings%2Bnews%26gbv%3D2%26%26ct%3Dclnk&sa=U&ei=qTUNVOalHMe2uATE_YGQDw&ved=0CB8QIDAD&usg=AFQjCNFx4v82ZSgfuIZHJmenK1Xv6jxYpw">Cached</a></li><li class="_Ykb"><a class="_Zkb" href="/search?hl=en-IN&gbv=2&q=related:en.wikipedia.org/wiki/Noida_serial_murders+nithari+killings%09news&tbo=1&sa=X&ei=qTUNVOalHMe2uATE_YGQDw&ved=0CCAQHzAD">Similar</a></li></ul></div></div></div><span class="st">The Noida serial <b>murders</b> (also <b>Nithari</b> serial <b>murders</b>, <b>Nithari</b> Kand) took ... The <br>
police then sealed the house and did not allow <b>news</b> media anywhere near the ...</span><br><div class="osl"><a href="/url?q=http://en.wikipedia.org/wiki/Noida_serial_murders%23Events_leading_to_primary_investigation&sa=U&ei=qTUNVOalHMe2uATE_YGQDw&ved=0CCIQ0gIoADAD&usg=AFQjCNFoFLoEv_CGAkKNe2WFNpQdqTyRag">Events leading to primary ...</a> - <a href="/url?q=http://en.wikipedia.org/wiki/Noida_serial_murders%23Primary_investigation&sa=U&ei=qTUNVOalHMe2uATE_YGQDw&ved=0CCMQ0gIoATAD&usg=AFQjCNFFSz2pBFdWoUAGkp2sZ_KpAmBoUg">Primary investigation</a> - <a href="/url?q=http://en.wikipedia.org/wiki/Noida_serial_murders%23CBI_investigation&sa=U&ei=qTUNVOalHMe2uATE_YGQDw&ved=0CCQQ0gIoAjAD&usg=AFQjCNHlovBCPUSSGlExpuZHJxtDHQUZ7A">CBI investigation</a> - <a href="/url?q=http://en.wikipedia.org/wiki/Noida_serial_murders%23Victims&sa=U&ei=qTUNVOalHMe2uATE_YGQDw&ved=0CCUQ0gIoAzAD&usg=AFQjCNFgkfguy3vUxvh8JmS-ncgfIxOLNA">Victims</a></div></div></li><li class="g"><h3 class="r"><a href="/url?q=http://www.ndtv.com/topic/nithari-killings&sa=U&ei=qTUNVOalHMe2uATE_YGQDw&ved=0CCcQFjAE&usg=AFQjCNESpfXGZ4DE-uVDo8LvQ42kHVU4Bg"><b>Nithari Killings</b>: Latest <b>News</b>, Photos, Videos on <b>Nithari</b> <b>...</b> - NDTV.com</a></h3><div class="s"><div class="kv" style="margin-bottom:2px"><cite>www.ndtv.com/topic/<b>nithari</b>-<b>killings</b></cite><div class="_nBb"><div style="display:inline" onclick="google.sham(this);" aria-expanded="false" aria-haspopup="true" tabindex="0" data-ved="0CCgQ7B0wBA"><span class="_O0"></span></div><div style="display:none" class="am-dropdown-menu" role="menu" tabindex="-1"><ul><li class="_Ykb"><a class="_Zkb" href="/url?q=http://webcache.googleusercontent.com/search%3Fhl%3Den-IN%26q%3Dcache:a6vXEobpypEJ:http://www.ndtv.com/topic/nithari-killings%252Bnithari%2Bkillings%2Bnews%26gbv%3D2%26%26ct%3Dclnk&sa=U&ei=qTUNVOalHMe2uATE_YGQDw&ved=0CCoQIDAE&usg=AFQjCNGiRwJ84qtiMaU-6ag_SMMyugi2-g">Cached</a></li><li class="_Ykb"><a class="_Zkb" href="/search?hl=en-IN&gbv=2&q=related:www.ndtv.com/topic/nithari-killings+nithari+killings%09news&tbo=1&sa=X&ei=qTUNVOalHMe2uATE_YGQDw&ved=0CCsQHzAE">Similar</a></li></ul></div></div></div><span class="st">Find <b>Nithari Killings</b> Latest <b>News</b>, Videos & Pictures on <b>Nithari Killings</b> and see <br>
latest updates, <b>news</b>, information from NDTV.COM. Explore more on <b>Nithari</b> ...</span><br></div></li><li class="g"><h3 class="r"><a href="/url?q=http://timesofindia.indiatimes.com/India/SC-stays-execution-of-Nithari-killer-Surinder-Koli/articleshow/41998225.cms&sa=U&ei=qTUNVOalHMe2uATE_YGQDw&ved=0CC0QFjAF&usg=AFQjCNHAHTcrXEtqeYz_1KPmz-6AxK93RA">SC stays execution of <b>Nithari</b> killer Surinder Koli - The Times of India</a></h3><div class="s"><div class="kv" style="margin-bottom:2px"><cite>timesofindia.indiatimes.com/India/SC...<b>Nithari</b>.../41998225.cms</cite><div class="_nBb"><div style="display:inline" onclick="google.sham(this);" aria-expanded="false" aria-haspopup="true" tabindex="0" data-ved="0CC4Q7B0wBQ"><span class="_O0"></span></div><div style="display:none" class="am-dropdown-menu" role="menu" tabindex="-1"><ul><li class="_Ykb"><a class="_Zkb" href="/url?q=http://webcache.googleusercontent.com/search%3Fhl%3Den-IN%26q%3Dcache:OvKjSrI26NwJ:http://timesofindia.indiatimes.com/India/SC-stays-execution-of-Nithari-killer-Surinder-Koli/articleshow/41998225.cms%252Bnithari%2Bkillings%2Bnews%26gbv%3D2%26%26ct%3Dclnk&sa=U&ei=qTUNVOalHMe2uATE_YGQDw&ved=0CDAQIDAF&usg=AFQjCNHV4qIIoJ8sR79KTPOCIyUhWNwwCg">Cached</a></li></ul></div>
@chopu: отсутствует двойные кавычки в: Pattern.compile ("??. (* (= \\ с * & амп <= д =))"); –
@AvinashRaj ваш ответ тоже прав. Но он дает мне только одну ссылку, а не весь набор ссылок, который удовлетворяет вышеуказанным правилам. Я не знаю, что пошло не так. – chopss
Вы добавили многострочный модификатор ?, 'Pattern.compile ("(? <= q = http:). *? (? = \\ s * & amp)", Pattern.MULTILINE); '. Смотрите мой ответ, он работает для меня. –