fork download
  1. class EmailValidator {
  2. function main(args: String[]) {
  3. System.out.println("Program started")
  4. var email = "example@domain.com"
  5.  
  6. if (isValidEmail(email)) {
  7. System.out.println(email + " is a valid email.")
  8. } else {
  9. System.out.println(email + " is not a valid email.")
  10. }
  11. }
  12.  
  13. function isValidEmail(email: String): Boolean {
  14. var regex = "^([a-zA-Z0-9_\\-\\.]+)@([a-zA-Z0-9_\\-\\.]+)\\.([a-zA-Z]{2,5})$"
  15. return email.matches(regex)
  16. }
  17. }
  18.  
Success #stdin #stdout 2.82s 168876KB
stdin
Standard input is empty
stdout
Standard output is empty