matching/dateMatchers.go
func dateWithoutSepMatchHelper(password string) (matches []match.DateMatch) {
	for _, v := range dateWithOutSepMatch.FindAllString(password, len(password)) {
		i := strings.Index(password, v)
		j := i + len(v)
		length := len(v)
		lastIndex := length - 1
		var candidatesRoundOne []dateMatchCandidate

		if length <= 6 {
			//2-digit year prefix
			candidatesRoundOne = append(candidatesRoundOne, buildDateMatchCandidate(v[2:], v[0:2], i, j))

			//2-digityear suffix
			candidatesRoundOne = append(candidatesRoundOne, buildDateMatchCandidate(v[0:lastIndex-2], v[lastIndex-2:], i, j))
		}
		if length >= 6 {
			//4-digit year prefix
			candidatesRoundOne = append(candidatesRoundOne, buildDateMatchCandidate(v[4:], v[0:4], i, j))

			//4-digit year sufix
			candidatesRoundOne = append(candidatesRoundOne, buildDateMatchCandidate(v[0:lastIndex-3], v[lastIndex-3:], i, j))
		}

		var candidatesRoundTwo []dateMatchCandidateTwo
		for _, c := range candidatesRoundOne {
			if len(c.DayMonth) == 2 {
				candidatesRoundTwo = append(candidatesRoundTwo, buildDateMatchCandidateTwo(c.DayMonth[0:0], c.DayMonth[1:1], c.Year, c.I, c.J))
			} else if len(c.DayMonth) == 3 {
				candidatesRoundTwo = append(candidatesRoundTwo, buildDateMatchCandidateTwo(c.DayMonth[0:2], c.DayMonth[2:2], c.Year, c.I, c.J))
				candidatesRoundTwo = append(candidatesRoundTwo, buildDateMatchCandidateTwo(c.DayMonth[0:0], c.DayMonth[1:3], c.Year, c.I, c.J))
			} else if len(c.DayMonth) == 4 {
				candidatesRoundTwo = append(candidatesRoundTwo, buildDateMatchCandidateTwo(c.DayMonth[0:2], c.DayMonth[2:4], c.Year, c.I, c.J))
			}
		}

		for _, candidate := range candidatesRoundTwo {
			intDay, err := strconv.ParseInt(candidate.Day, 10, 16)
			if err != nil {
				continue
			}

			intMonth, err := strconv.ParseInt(candidate.Month, 10, 16)

			if err != nil {
				continue
			}

			intYear, err := strconv.ParseInt(candidate.Year, 10, 16)
			if err != nil {
				continue
			}

			if ok, _, _, _ := checkDate(intDay, intMonth, intYear); ok {
				matches = append(matches, match.DateMatch{Token: password, Pattern: "date", Day: intDay, Month: intMonth, Year: intYear, I: i, J: j})
			}

		}
	}

	return matches
}
func dateWithoutSepMatchHelper(password string) (matches []match.DateMatch) {
	for _, v := range dateWithOutSepMatch.FindAllString(password, len(password)) {
		i := strings.Index(password, v)
		j := i + len(v)
		length := len(v)
		lastIndex := length - 1
		var candidatesRoundOne []dateMatchCandidate

		if length <= 6 {
			//2-digit year prefix
			candidatesRoundOne = append(candidatesRoundOne, buildDateMatchCandidate(v[2:], v[0:2], i, j))

			//2-digityear suffix
			candidatesRoundOne = append(candidatesRoundOne, buildDateMatchCandidate(v[0:lastIndex-2], v[lastIndex-2:], i, j))
		}
		if length >= 6 {
			//4-digit year prefix
			candidatesRoundOne = append(candidatesRoundOne, buildDateMatchCandidate(v[4:], v[0:4], i, j))

			//4-digit year sufix
			candidatesRoundOne = append(candidatesRoundOne, buildDateMatchCandidate(v[0:lastIndex-3], v[lastIndex-3:], i, j))
		}

		var candidatesRoundTwo []dateMatchCandidateTwo
		for _, c := range candidatesRoundOne {
			if len(c.DayMonth) == 2 {
				candidatesRoundTwo = append(candidatesRoundTwo, buildDateMatchCandidateTwo(c.DayMonth[0:0], c.DayMonth[1:1], c.Year, c.I, c.J))
			} else if len(c.DayMonth) == 3 {
				candidatesRoundTwo = append(candidatesRoundTwo, buildDateMatchCandidateTwo(c.DayMonth[0:2], c.DayMonth[2:2], c.Year, c.I, c.J))
				candidatesRoundTwo = append(candidatesRoundTwo, buildDateMatchCandidateTwo(c.DayMonth[0:0], c.DayMonth[1:3], c.Year, c.I, c.J))
			} else if len(c.DayMonth) == 4 {
				candidatesRoundTwo = append(candidatesRoundTwo, buildDateMatchCandidateTwo(c.DayMonth[0:2], c.DayMonth[2:4], c.Year, c.I, c.J))
			}
		}

		for _, candidate := range candidatesRoundTwo {
			intDay, err := strconv.ParseInt(candidate.Day, 10, 16)
			if err != nil {
				continue
			}

			intMonth, err := strconv.ParseInt(candidate.Month, 10, 16)

			if err != nil {
				continue
			}

			intYear, err := strconv.ParseInt(candidate.Year, 10, 16)
			if err != nil {
				continue
			}

			if ok, _, _, _ := checkDate(intDay, intMonth, intYear); ok {
				matches = append(matches, match.DateMatch{Token: password, Pattern: "date", Day: intDay, Month: intMonth, Year: intYear, I: i, J: j})
			}

		}
	}

	return matches
}
func dateWithoutSepMatchHelper ( password string ) ( matches [ ] match . DateMatch ) { for _ , v := range dateWithOutSepMatch . FindAllString ( password , len ( password ) ) { i := strings . Index ( password , v ) j := i + len ( v ) length := len ( v ) lastIndex := length - 1 var candidatesRoundOne [ ] dateMatchCandidate if length <= 6 { //2-digit year prefix candidatesRoundOne = append ( candidatesRoundOne , buildDateMatchCandidate ( v [ 2 : ] , v [ 0 : 2 ] , i , j ) ) //2-digityear suffix candidatesRoundOne = append ( candidatesRoundOne , buildDateMatchCandidate ( v [ 0 : lastIndex - 2 ] , v [ lastIndex - 2 : ] , i , j ) ) } if length >= 6 { //4-digit year prefix candidatesRoundOne = append ( candidatesRoundOne , buildDateMatchCandidate ( v [ 4 : ] , v [ 0 : 4 ] , i , j ) ) //4-digit year sufix candidatesRoundOne = append ( candidatesRoundOne , buildDateMatchCandidate ( v [ 0 : lastIndex - 3 ] , v [ lastIndex - 3 : ] , i , j ) ) } var candidatesRoundTwo [ ] dateMatchCandidateTwo for _ , c := range candidatesRoundOne { if len ( c . DayMonth ) == 2 { candidatesRoundTwo = append ( candidatesRoundTwo , buildDateMatchCandidateTwo ( c . DayMonth [ 0 : 0 ] , c . DayMonth [ 1 : 1 ] , c . Year , c . I , c . J ) ) } else if len ( c . DayMonth ) == 3 { candidatesRoundTwo = append ( candidatesRoundTwo , buildDateMatchCandidateTwo ( c . DayMonth [ 0 : 2 ] , c . DayMonth [ 2 : 2 ] , c . Year , c . I , c . J ) ) candidatesRoundTwo = append ( candidatesRoundTwo , buildDateMatchCandidateTwo ( c . DayMonth [ 0 : 0 ] , c . DayMonth [ 1 : 3 ] , c . Year , c . I , c . J ) ) } else if len ( c . DayMonth ) == 4 { candidatesRoundTwo = append ( candidatesRoundTwo , buildDateMatchCandidateTwo ( c . DayMonth [ 0 : 2 ] , c . DayMonth [ 2 : 4 ] , c . Year , c . I , c . J ) ) } } for _ , candidate := range candidatesRoundTwo { intDay , err := strconv . ParseInt ( candidate . Day , 10 , 16 ) if err != nil { continue } intMonth , err := strconv . ParseInt ( candidate . Month , 10 , 16 ) if err != nil { continue } intYear , err := strconv . ParseInt ( candidate . Year , 10 , 16 ) if err != nil { continue } if ok , _ , _ , _ := checkDate ( intDay , intMonth , intYear ) ; ok { matches = append ( matches , match . DateMatch { Token : password , Pattern : " " , Day : intDay , Month : intMonth , Year : intYear , I : i , J : j } ) } } } return matches }
//TODO Has issues with 6 digit dates
TODO Has issues with 6 digit dates