I have this regex expression that work on regex101.
But in my python code, it is returning None.
If you guys can help me out that would be great.
Link to my regex expression
https://regex101.com/r/T0Jvq4/1
This is my function.
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 ""
Thank you
>Solution :
I would suggest simplifying your pattern and just use dot all mode:
def tryRegexData(area):
try:
return re.search(r'\bLegal Description:\s+(.*?)\s+Property Use:', area.text, flags=re.S).group(1)
except Exception as e:
return ""