I know this is a part of an exercise, but it feels like a lot of wheel reinventing where you can leverage builtin Python capabilities for date validation:

    from datetime import date
    
    >>> date(2020, 2, 29) # leap year date works
    datetime.date(2020, 2, 29)
    
    >>> date(2002, 2, 29) # non-leap year will raise ValueError
    ValueError: day is out of range for month
    
    >>> date(2002, 9, 31) # 31th day will raise ValueError
    ValueError: day is out of range for month


- instead of creating 3 separate lists for **years**, **months** and **days**, you can create only one list, since you always access these parts at the same index. That also simplifies the `for` loop which gives you the values directly instead of giving you an index you want to access in these lists.



```python
import re
from datetime import date

def date_detector(text):
    date_pattern = re.compile('''
    ([12][0-9]|3[0-1]|0?[1-9])             # to detect days from 1 to 31
    ([./-])                                # to detect different separations
    (1[0-2]|0?[1-9])                       # to detect number of months
    ([./-])                                # to detect different seperations
    (2?1?[0-9][0-9][0-9])                  # to detect number of years from 1000-2999 years
        ''', re.VERBOSE)

    parsed = []
    for match in date_pattern.findall(text):
        # year, month, day for easier passing to date()
        parsed.append([ int(match[4]), int(match[2]), int(match[0])] )

    valid = []
    for item in parsed:
        try:
            date(*item)
        except ValueError as e:
            pass # invalid date, dont do anything
        else:
            valid.append(item)

    for item in valid:
        print(item)


data = '30-06-2012, 31-12-2012, 15-02-2002, 29-02-2004, 29-02-2002, 31-02-2004, 31-06-2012'

date_detector(data)
```