43 lines
672 B
Go
Executable File
43 lines
672 B
Go
Executable File
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"regexp"
|
|
"strings"
|
|
)
|
|
|
|
func splitTest() {
|
|
|
|
bucketName := "123"
|
|
suffix := ""
|
|
if strings.Contains(bucketName, "/") {
|
|
splitN := strings.SplitN(bucketName, "/", 2)
|
|
bucketName = splitN[0]
|
|
if !strings.HasSuffix(splitN[1], "/") {
|
|
splitN[1] = splitN[1] + "/"
|
|
}
|
|
suffix = splitN[1]
|
|
|
|
}
|
|
|
|
fmt.Println(bucketName)
|
|
fmt.Println(suffix)
|
|
}
|
|
|
|
func main() {
|
|
|
|
inputList := []string{
|
|
"4.1.6-xxx",
|
|
"5.1.0",
|
|
"3.2.0-0123-123",
|
|
}
|
|
r, _ := regexp.Compile(`\d+.+\d+.+\d+`)
|
|
for _, input := range inputList {
|
|
matches := r.FindAllString(input, -1)
|
|
for _, match := range matches {
|
|
fmt.Println(match) // Output: 4.1.6 5.1.0 3.2.0
|
|
}
|
|
}
|
|
|
|
}
|