-1

Hello I am trying to extract with regex the number before , after and between the dot/s ,here is my code and it works just for the pattern1 , meanly just when i look after the number before the dot

perioada = "12.41.2007"
pattern1 = re.compile(r"\d+(?=\.)")

m1 = pattern1.match(perioada)
pattern2 = re.compile(r'(?<=\.)\d+(?=\.)')
m2 = pattern2.match('12.41.2007')
pattern3 = re.compile(r'(?<=\.)\d+')
m3 = pattern3.match(perioada)
print(pattern1.search(perioada))
print (m3)
print("ziua: ", m1.group(0))
print("luna: ", m2.group(0))
print("anu: ", m3.group(0))
Ursubrun
  • 1
  • 1

0 Answers0