mirror of
https://codeberg.org/aryak/mozhi
synced 2024-11-17 00:13:01 +05:30
15 lines
374 B
Go
15 lines
374 B
Go
package utils
|
|
|
|
import "regexp"
|
|
|
|
func Sanitize(str string, strip string) string {
|
|
nonAlphanumericRegex := regexp.MustCompile(`[^a-zA-Z]+`)
|
|
nonAlphaRegex := regexp.MustCompile(`[^a-zA-Z0-9]+`)
|
|
if strip == "alpha" {
|
|
return nonAlphaRegex.ReplaceAllString(str, "")
|
|
} else if strip == "alphanumeric" {
|
|
return nonAlphanumericRegex.ReplaceAllString(str, "")
|
|
}
|
|
return ""
|
|
}
|