From 0f837658e05d6af71430fd212f8f73f21a218e3e Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Tue, 24 Dec 2019 18:46:03 +0100 Subject: [PATCH] Add method to clean license plates Signed-off-by: Knut Ahlers --- block_trailer.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/block_trailer.go b/block_trailer.go index 62c0331..08de2aa 100644 --- a/block_trailer.go +++ b/block_trailer.go @@ -1,5 +1,10 @@ package sii +import ( + "regexp" + "strings" +) + func init() { RegisterBlock(&Trailer{}) } @@ -30,3 +35,13 @@ func (t *Trailer) Init(class, name string) { } func (t Trailer) Name() string { return t.blockName } + +func (t Trailer) CleanedLicensePlate() string { + return regexp.MustCompile(` +`).ReplaceAllString( + regexp.MustCompile(`<[^>]+>`).ReplaceAllString( + strings.Split(t.LicensePlate, "|")[0], + " ", + ), + " ", + ) +}