I have the following code to match the dates
import re date_reg_exp2 = re.compile(r'\d{2}([-/.])(\d{2}|[a-zA-Z]{3})\1(\d{4}|\d{2})|\w{3}\s\d{2}[,.]\s\d{4}') matches_list = date_reg_exp2.findall("23-SEP-2015 and 23-09-2015 and 23-09-15 and Sep 23, 2015") print matches_list The output I expect is
["23-SEP-2015","23-09-2015","23-09-15","Sep 23, 2015"] What I am getting is:
[('-', 'SEP', '2015'), ('-', '09', '2015'), ('-', '09', '15'), ('', '', '')] Please check the link for regex here.
(may be in the wrong place - the first two numbers are not captured, the first thing you've told it to capture is the[-/.]sequence"23-SEP-2015 and 23-09-2015 and 23-09-15 and Sep 23, 2015".split(' and ')in this case?and. It can beThis string is 23-09-2015 and It can also be something. I need a match saying['23-09-2015']regexIf you can help me with the above expression that would be great.