2013-10-01 51 views
0

我想知道什麼是該適當的正則表達式:如何爲這個html字符串生成正則表達式?

In an action unprecedented during 12 years of war in Afghanistan, the commandant of the Marine Corps is firing two top generals. See why: 

<a onmouseover="LinkshimAsyncLin.swap()>Generals fired over Taliban attack </a><br/>security.blogs.cnn.com<br/>There were three investigations of the incident. 

我要做到以下幾點:

給我a tag包含onmouseover="LinkshimAsyncLin.swap()在任何位置在屬性區域的字符串開始..並與保持字符串的結束而終止.. 我從這個標籤意味着字符串

結束注意:

我的朋友,我都知道,使用正則表達式的HTML標籤是非常糟糕的做法,我已經有小紅說了很多,但我想,對於特殊情況

+1

真正偉大的音符:) – alecxe

+1

看起來你剛剛在StackOverflow而不是在你的筆記本上寫了一個簡短的當前任務。顯示你的嘗試並解釋你的_specific_問題。 StackOverflow是不是在這裏爲你做你的工作 – Bojangles

+0

我不知道任何關於正則表達式,但我希望這個表達迫切請 –

回答

0

試試這個:

(?i)[^<>]++(?=<a\\b(?>[^>o]++|\\Bo++|o(?!nmouseover\\b))++onmouseover\\s*=\\s*[\"']?LinkshimAsyncLin\\.swap\\(\\)(?>[\"']|\\s|(?=>))) 
+0

它不工作 –

相關問題