19 lines
403 B
Go
19 lines
403 B
Go
package davextra
|
|
|
|
import (
|
|
"regexp"
|
|
)
|
|
|
|
// GetLinkFragment returns the longest alphanumeric string from a link
|
|
func GetLinkFragment(link string) string {
|
|
re := regexp.MustCompile(`\w+`)
|
|
matches := re.FindAllString(link, -1) // Returns all matches
|
|
var longestMatch string
|
|
for _, match := range matches {
|
|
if len(match) > len(longestMatch) {
|
|
longestMatch = match
|
|
}
|
|
}
|
|
return longestMatch[:4]
|
|
}
|