RegEx needed for Wikipedia infobox

匿名 (未验证) 提交于 2019-12-03 01:48:02

问题:

OK, so here's what I need :

  • We have the full XML of a Wikipedia article
  • We need just the Infobox section

I have tried various things, but my main issue seems to be not being able to matching "internal" curly brackets. Any ideas (or any regex you have managed to get this done?)

For those of you who do not know what I'm talking about, here's a (somewhat abridged) example of what I'm trying to parse : http://regexr.com?38299

(What is needed is the part between {{Infobox ******* up to its corresponding closing brackets (}}).

回答1:

Ok, I got it!

Try this..:

(?=\{Infobox)(\{([^{}]|(?1))*\}) 

Here's the working example:

http://regex101.com/r/kT1jF4



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!