【发布时间】:2014-01-22 13:35:53
【问题描述】:
所以我得到了一个巨大的字符串,我开始搜索
"<div style=\"font-size:15px;\"><b>"
和
"</b></div>"
就像这样:(它实际上是一个 IF 语句。)
htmlCode.contains("<div style=\"font-size:15px;\"><b>")
&& htmlCode.contains("</b></div>")
无论如何,在第一个"<div style=\"font-size:15px;\"><b>" 之后是文本,在文本之后是第二个。 ("</b></div>")
现在,我想“获取”那段文本,并最终删除到其他文本,只保留“中间文本”。
我找了好久,没找到解决办法。
如果你能给我发一个文档链接,或者一个例子,那就太好了。
额外信息:
/*
* 1. Search for "<div style="font-size:15px;"><b>" ** TITLE COMES HERE **
* 2. Search for "</b></div>" ** This is after the Title, so Title is between 1 and 2.
* 3. Search for "<div style="float:left;"><a href="" ** Link Comes Here **
* 4. Search for "" rel="nofollow" target="_blank" style="color:green;">" ** Same as 2. // Link Instead **
*
* -- How it should do it --
* 1 -> Wait -> 2 -> Wait -> Get the text between 1 and 2 -> Save in String (Array) -> 3 -> Wait -> 4 -> Wait
* -> Get the text between 3 and 4 -> Save in String (Array) -> Repeat Process (Max 25(?)).
*/
完整字符串的示例如下:
<div style="font-size:15px;"><b>**My Little Pony.**</b></div>
(加星标的文字是我想要得到的)
提前致谢!
【问题讨论】: