Öffentliche Dateiansicht: Raw-Dateien, Tree, Releases und Issues sind ohne Login verfügbar.
internal/detector/vatid.go Raw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package detector

import (
	"regexp"
	"strings"
)

var vatIDRE = regexp.MustCompile(`\bDE ?[0-9]{3} ?[0-9]{3} ?[0-9]{3}\b`)

func detectVATID(text string) []Finding {
	var out []Finding
	for _, loc := range vatIDRE.FindAllStringIndex(text, -1) {
		raw := text[loc[0]:loc[1]]
		if len(strings.ReplaceAll(raw, " ", "")) != 11 {
			continue
		}
		out = append(out, Finding{
			Type: PiiVATID, Start: loc[0], End: loc[1],
			Text: raw, Confidence: 0.85,
		})
	}
	return out
}