0

I'm getting (HTTP request) and I'm trying to get certain data out of it by using a regex, for example this part of the HTML:

<tr><th>Continent:</th><td class='trc'>Europe (EU)</td></tr>

How can I get the 'Europe (EU)' out of this?

I've tried this regex:

/<th>Continent:<\/th><td class='trc'>(.+)\s<\/td>/

But this does not work

4

1 回答 1

2

你告诉正则表达式寻找一个空格,然后</td>

/<th>Continent:<\/th><td class='trc'>(.+)\s<\/td>/  
                                         ^^

我建议使用[^<>]+在 html 标签之间搜索文本。

/<th>Continent:<\/th><td class='trc'>([^<>]+)<\/td>/
于 2013-05-05T14:20:28.343 回答