Skip to main content
 首页 » 编程设计

python之使用正则表达式提取第一段

2025年05月04日23arxive

我正在尝试提取第一段。但我找到了任何运气。谁能帮我?这是文字。 http://dpaste.com/638776/ .我的文字是动态的。谢谢

更新:我正在使用 eTree 模块读取 XML 文件。在 XML 中有一个名为 <text></text> 的标签. <text></text>之间的数据is here .我只想打印来自 text tags 的以下数据.是否可以?谢谢

  '''Zamindar''' ({{te|జమీందార్}}) is a 1965 [[Telugu language|Telugu]] "Thriller" film  
  directed by [[V. Madhusudhan Rao]] and produced by [[Tammareddy Krishna Murthy]]  
  of Ravindra Art Pictures.This is variety role for [[Akkineni Nageswara Rao]] 
  who is more popular with soft Romantic roles.He plays the role of a tough CID Officer     very well.The Movie has some Good songs.This movie has a considerable resemblance with the 1963 [[Cary Grant]] English Movie ''[[Charade (1963 film)|Charade]]''. 

请您参考如下方法:

如果您在点与换行符匹配的地方构建了一个正则表达式,那么您已经(在 ruby​​ 中进行了测试,但我猜它会按原样在 python 中工作)。这与 Niall Byrne 的回答完全相同:

}}\n(.*?)\n\n 

效果请看rubular .