Created
May 11, 2016 18:57
-
-
Save netologist/43b27520f093f554ecb2811326a72b62 to your computer and use it in GitHub Desktop.
validations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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