如何使用正则表达式从特定点到文本末尾?

时间:2013-10-02 20:56:24

标签: regex

我想知道正确的正则表达式是什么:

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.

我想做以下事情:

给我一​​个标签的字符串开头,该标签在属性区域的任何位置包含onmouseover =“LinkshimAsyncLin.swap()”,并以保留字符串的结尾结束。我的意思是从这个标签到字符串的结尾

我的尝试: -

我使用了这种模式:

<a[^>]*?onmouseover\\s*=\\s*['\"]([^'\"]*?)['\"][^>]*?/?>

它成功完成了此部分<a onmouseover="LinkshimAsyncLin.swap()> 我想得到所有剩余标签和文字到终点

注意:

我的朋友们,我知道使用带有html标签的正则表达式是非常糟糕的做法,而且我已经有了很多红色,但我想要特殊情况

提前谢谢:)

1 个答案:

答案 0 :(得分:3)

这是你想要的吗?

onmouseover.*
相关问题