在java中编写正则表达式代码以获取以下数据

时间:2010-04-01 06:57:19

标签: java regex

    <table> 
<tr> 
<td style="width:180px"> 
<a href="/search?q=user:240698+[java]" class="post-tag" title="show all posts by this user in 'java'">java</a><span class="item-multiplier">&times;&nbsp;176</span><br> 
<a href="/search?q=user:240698+[servlets]" class="post-tag" title="show all posts by this user in 'servlets'">servlets</a><span class="item-multiplier">&times;&nbsp;25</span><br> 
<a href="/search?q=user:240698+[jsp]" class="post-tag" title="show all posts by this user in 'jsp'">jsp</a><span class="item-multiplier">&times;&nbsp;11</span><br> 
<a href="/search?q=user:240698+[core]" class="post-tag" title="show all posts by this user in 'core'">core</a><span class="item-multiplier">&times;&nbsp;9</span><br> 
</tr>
</table>

从上面的代码我只需要获取java,servlets,jsp和core。

有人可以帮助我在java中编写一个正则表达式来获取那些吗?

由于

2 个答案:

答案 0 :(得分:2)

don't使用正则表达式解析HTML,改为使用HTML parsers

答案 1 :(得分:1)

如果我必须使用正则表达式,我会尝试

"/search\?q=user:\d+\+\[(\w*)\]"