class EmailValidator {
function main(args: String[]) {
var email = "example@domain.com"
if (isValidEmail(email)) {
System.out.println(email + " is a valid email.")
} else {
System.out.println(email + " is not a valid email.")
}
}
function isValidEmail(email: String): Boolean {
var regex = "^([a-zA-Z0-9_\\-\\.]+)@([a-zA-Z0-9_\\-\\.]+)\\.([a-zA-Z]{2,5})$"
return email.matches(regex)
}
}
Y2xhc3MgRW1haWxWYWxpZGF0b3IgewogIGZ1bmN0aW9uIG1haW4oYXJnczogU3RyaW5nW10pIHsKICAgIHZhciBlbWFpbCA9ICJleGFtcGxlQGRvbWFpbi5jb20iCiAgICAKICAgIGlmIChpc1ZhbGlkRW1haWwoZW1haWwpKSB7CiAgICAgIFN5c3RlbS5vdXQucHJpbnRsbihlbWFpbCArICIgaXMgYSB2YWxpZCBlbWFpbC4iKQogICAgfSBlbHNlIHsKICAgICAgU3lzdGVtLm91dC5wcmludGxuKGVtYWlsICsgIiBpcyBub3QgYSB2YWxpZCBlbWFpbC4iKQogICAgfQogIH0KICAKICBmdW5jdGlvbiBpc1ZhbGlkRW1haWwoZW1haWw6IFN0cmluZyk6IEJvb2xlYW4gewogICAgdmFyIHJlZ2V4ID0gIl4oW2EtekEtWjAtOV9cXC1cXC5dKylAKFthLXpBLVowLTlfXFwtXFwuXSspXFwuKFthLXpBLVpdezIsNX0pJCIKICAgIHJldHVybiBlbWFpbC5tYXRjaGVzKHJlZ2V4KQogIH0KfQo=