feat:#51 added mapping for room schedule request

This commit is contained in:
Elmar Kresse
2024-08-17 18:10:46 +02:00
parent db86ae7206
commit 91d56493c8
7 changed files with 120 additions and 36 deletions

View File

@@ -0,0 +1,24 @@
package functions
import (
"regexp"
"strings"
)
func MapRoom(room string) string {
// remove dots from room string
room = strings.ReplaceAll(room, ".", "")
// Regular expression pattern to match room identifiers
// The pattern looks for strings that start with two uppercase letters, optionally followed by an underscore,
// followed by 1 to 3 digits, and ending with "-[A-Z]"
re := regexp.MustCompile(`\b[A-ZÄÖÜ]{2}([_]+[A-ZÄÖÜ])?[0-9]{1,4}[a-zäöü]?-[A-ZÄÖÜ]\b`)
// Use the ReplaceAllStringFunc to process each match
result := re.ReplaceAllStringFunc(room, func(match string) string {
// Remove the last two characters (i.e., "-<letter>")
return match[:len(match)-2]
})
return result
}