I need to extract a date from a jpeg format, I have extracted the text from the jpeg in the form of a string & have used regex to extract the date,
Text from JPEG
Cont:7225811153; BillNo4896TableNoR306 07-Jun-201921:18:40
Code used
Importing regular expression & Date time
import re as r
from datetime import datetime
regex to identify the date in the above string
id = r.search(r'\d{2}-\w{3}-\d{4}',text)
print(id)
Output re.Match object; span=(89, 100), match='07-Jun-2019'
However after performing the above code i tried the following to extract the date
Code
Extracting the date
date = datetime.strptime(id.group(),'%d-%B-%Y').date()
Output
ValueError: time data '07-Jun-2019' does not match format '%d-%B-%Y'
Where am I going wrong, or is there a better way to do the same. Help would be really appreciated