I am using tesseract to extract Information for a driving licence. So i want to check if the extracted Information is correct. For example when i want to get the date of birth, it should be like this: 15.08.1999 ==> 2 int. 2 int. 4 int How can i do this? the second question is: sometimes the extracted info contains no points. I mean like this: 15 08 1999 So how can i check if there is a point in the second position of the string and if not put a point. Could someone help with this? Thanks
Use a regular expression that extracts the components of the date in either format.
import re
match = re.match(r'(\d{2})[. ](\d{2})[. ](\d{4})$', birthdate)
if match:
day, month, year = match.groups()
[. ]
[. ]
will match either a .
or space.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.