Skip to content

Instantly share code, notes, and snippets.

@netologist
Created May 11, 2016 18:57
Show Gist options
  • Save netologist/43b27520f093f554ecb2811326a72b62 to your computer and use it in GitHub Desktop.
Save netologist/43b27520f093f554ecb2811326a72b62 to your computer and use it in GitHub Desktop.
validations
package main
import (
"fmt"
"regexp"
)
// Turkish Alpabetic Numeric "(),\-./"
func IsAlphaNumeric(text string) (ok bool) {
ok, _ = regexp.MatchString("^([\\(\\)\\,\\\\\\-\\./ a-zA-ZğüşıöçĞÜŞİÖÇ0-9]+)$", text)
return
}
func main() {
username := "100. Hello - / \\ ()plağüyground"
if IsAlphaNumeric(username) {
fmt.Println("Hello, playground")
} else {
fmt.Println("Noooo")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment