class EmailValidator {
function main(args: String[]) {
var email = "example@domain.com"
if (isValidEmail(email)) {
print(email + " is a valid email.")
} else {
print(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)
}
}
Y2xhc3MgRW1haWxWYWxpZGF0b3IgewogIGZ1bmN0aW9uIG1haW4oYXJnczogU3RyaW5nW10pIHsKICAgIHZhciBlbWFpbCA9ICJleGFtcGxlQGRvbWFpbi5jb20iCiAgICAKICAgIGlmIChpc1ZhbGlkRW1haWwoZW1haWwpKSB7CiAgICAgIHByaW50KGVtYWlsICsgIiBpcyBhIHZhbGlkIGVtYWlsLiIpCiAgICB9IGVsc2UgewogICAgICBwcmludChlbWFpbCArICIgaXMgbm90IGEgdmFsaWQgZW1haWwuIikKICAgIH0KICB9CiAgCiAgZnVuY3Rpb24gaXNWYWxpZEVtYWlsKGVtYWlsOiBTdHJpbmcpOiBCb29sZWFuIHsKICAgIHZhciByZWdleCA9ICJeKFthLXpBLVowLTlfXFwtXFwuXSspQChbYS16QS1aMC05X1xcLVxcLl0rKVxcLihbYS16QS1aXXsyLDV9KSQiCiAgICByZXR1cm4gZW1haWwubWF0Y2hlcyhyZWdleCkKICB9Cn0K