init code

This commit is contained in:
thuanle
2024-10-24 09:53:23 +07:00
parent a7559b3f9d
commit 92a63c7885
43 changed files with 1115 additions and 0 deletions

View 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
}

View File

@@ -0,0 +1,9 @@
package stringx
import "regexp"
func IsAlphaNumeric(s string) bool {
match, _ := regexp.MatchString("^[a-zA-Z0-9]*$", s)
return match
}