开发者

matching this html element in regex? (without lazy matching!)

I'd like to match everything between tags.

what's the regex to do that?

A bit like

  <tr[^>]*>开发者_如何学C.*?</tr> 

But I'd like to not use lazy evaluation.

I want to match each pair like the regex above, but not using lazy evaluation.


Instead of matching lazily, you could use a negative lookahead (if your flavour supports that). Your example would translate to

 <tr[^>]*>((?!</tr>).)*</tr>  

Of course, you should actually not use regex to parse HTML, as you might have guessed from the comments to your question. =) These expressions may fail horribly on nested tags, comments, and javascript.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜