regular expression to remove links

Possible Duplicate:
RegEx match open tags except XHTML self-contained tags

I have a HTML page with

<a class="development" href="[variable content]">X</a>

The [variable content] is different in each place, the rest is the same.
What regexp will catch all of those links? (Although I am not writing it here, I did try...)


那么非贪婪的版本呢?

<a class="development" href="(.*?)">X</a>

试试这个正则表达式:

<a class="development" href="[^"]*">X</a>

Regexes are fundamentally bad at parsing HTML (see Can you provide some examples of why it is hard to parse XML and HTML with a regex? for why). What you need is an HTML parser. See Can you provide an example of parsing HTML with your favorite parser? for examples using a variety of parsers.

链接地址: http://www.djcxy.com/p/76852.html

上一篇: 正则表达式去除Div标签

下一篇: 正则表达式去除链接