class EmailValidator {
function main(args: String[]) {
System.out.println("Program started")
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)
}
}
Y2xhc3MgRW1haWxWYWxpZGF0b3IgewogIGZ1bmN0aW9uIG1haW4oYXJnczogU3RyaW5nW10pIHsKICAgIFN5c3RlbS5vdXQucHJpbnRsbigiUHJvZ3JhbSBzdGFydGVkIikKICAgIHZhciBlbWFpbCA9ICJleGFtcGxlQGRvbWFpbi5jb20iCiAgICAKICAgIGlmIChpc1ZhbGlkRW1haWwoZW1haWwpKSB7CiAgICAgIFN5c3RlbS5vdXQucHJpbnRsbihlbWFpbCArICIgaXMgYSB2YWxpZCBlbWFpbC4iKQogICAgfSBlbHNlIHsKICAgICAgU3lzdGVtLm91dC5wcmludGxuKGVtYWlsICsgIiBpcyBub3QgYSB2YWxpZCBlbWFpbC4iKQogICAgfQogIH0KCiAgZnVuY3Rpb24gaXNWYWxpZEVtYWlsKGVtYWlsOiBTdHJpbmcpOiBCb29sZWFuIHsKICAgIHZhciByZWdleCA9ICJeKFthLXpBLVowLTlfXFwtXFwuXSspQChbYS16QS1aMC05X1xcLVxcLl0rKVxcLihbYS16QS1aXXsyLDV9KSQiCiAgICByZXR1cm4gZW1haWwubWF0Y2hlcyhyZWdleCkKICB9Cn0K