init code
This commit is contained in:
11
internal/utils/stringx/replace.go
Normal file
11
internal/utils/stringx/replace.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package stringx
|
||||
|
||||
import "strings"
|
||||
|
||||
func ReplaceSuffix(s string, suffix string, newSuffix string) (string, bool) {
|
||||
if strings.HasSuffix(s, suffix) {
|
||||
replaced := s[:len(s)-len(suffix)] + newSuffix
|
||||
return replaced, true
|
||||
}
|
||||
return s, false
|
||||
}
|
||||
9
internal/utils/stringx/validation.go
Normal file
9
internal/utils/stringx/validation.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package stringx
|
||||
|
||||
import "regexp"
|
||||
|
||||
func IsAlphaNumeric(s string) bool {
|
||||
match, _ := regexp.MatchString("^[a-zA-Z0-9]*$", s)
|
||||
return match
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user