Py学习  »  Python

我的Python正则表达式在代码中工作不正常

Phiking • 3 年前 • 1540 次点击  

我有一个正则表达式,它适用于regex101。 但在我的python代码中,它没有返回任何值。 如果你们能帮我,那就太好了。

链接到我的正则表达式 https://regex101.com/r/T0Jvq4/1

这是我的职责。

legalDescription = tryRegexData(r"(?<=Legal Description:)(\n)(.*)^(?:(?!Property Use:).)*",propertyArea,0)

def tryRegexData(regex,area,num):

  try: 
      return re.search(regex,area.text).group(num).strip()
  except Exception as e:
      return ""

非常感谢。

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/129920
 
1540 次点击  
文章 [ 2 ]  |  最新文章 3 年前