I’m trying to catch day, month and year by regex by this pattern:
<code>day_month_year_pattern = re.compile('(?:ngay|mong|mungs*)?(d{1,2})(?:s*thangs*|-|/)?(d{1,2})(?:s*nams|-|/)?(d{4})')
</code>
<code>day_month_year_pattern = re.compile('(?:ngay|mong|mungs*)?(d{1,2})(?:s*thangs*|-|/)?(d{1,2})(?:s*nams|-|/)?(d{4})')
</code>
day_month_year_pattern = re.compile('(?:ngay|mong|mungs*)?(d{1,2})(?:s*thangs*|-|/)?(d{1,2})(?:s*nams|-|/)?(d{4})')
but the space could be placed between hyphens like: 12 – 2 – 1945.
I tried (?:s*(thang|-|/))s*)?
but it gives me ('12', '-', '2', '1934')
if I pass 12-2-1945
. I just want it returns 3 elements day, month and year.
New contributor
panda is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1