(s string)
| 6 | ) |
| 7 | |
| 8 | func IsEmail(s string) (string, error) { |
| 9 | // Used a raw string here so I didn't have |
| 10 | // to double backslashes |
| 11 | r, _ := regexp.Compile(`[\w._%+-]{1,20}@[\w.-]{2,20}.[A-Za-z]{2,3}`) |
| 12 | |
| 13 | if r.MatchString(s) { |
| 14 | return "Valid Email", nil |
| 15 | } else { |
| 16 | return "", fmt.Errorf("not a valid email") |
| 17 | } |
| 18 | } |