2012-04-03 78 views
1

我需要的一切bewteen得到部分與正則表達式

onmouseout="this.style.backgroundColor='#fff'"> 

及以下在這種情況下<

onmouseout="this.style.backgroundColor='#fff'">example< 

我想獲得這個詞的例子。 這裏是它應該工作,以及更復雜的例子:

onmouseout="this.style.backgroundColor='#fff'">going to drink?<br></span><span title="Juist!" onmouseover="this.style.backgroundColor='#ebeff9'" onmouseout="this.style.backgroundColor='#fff'">Exactly!</span></span></div></div> 

所以在這裏我需要他們的2回(不加入)。

有人可以幫忙嗎?我吮吸正則表達式。

有人將我的標籤編輯爲javascript。 我需要一個在java中使用的解決方案,我只是以純文本形式獲取文件。所以JavaScript或HTML解決方案並不真正有用。

+1

http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454 – 2012-04-03 21:19:10

回答

2

正則表達式與html?那麼,如果你只需要解析幾行然後就可以了。但通常情況下最好使用html解析器(因爲HTML不是常規語言)。

這是純金:https://stackoverflow.com/a/1732454/434171