mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender.git
synced 2025-08-08 04:39:13 +02:00
feat:#51 added mapping for room schedule request
This commit is contained in:
24
services/data-manager/service/functions/roomMapping.go
Normal file
24
services/data-manager/service/functions/roomMapping.go
Normal 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
|
||||
}
|
Reference in New Issue
Block a user