isEmail static method

bool isEmail(
  1. String input
)

Return whether input matches regex of email.

Uses the non-backtracking RegexConstants.REGEX_EMAIL pattern and caps the input at 254 characters per RFC 5321 to bound the work for pathological inputs. The pattern is intentionally permissive about the local part (any non-space, non-@ character is allowed).

Implementation

static bool isEmail(String input) {
  if (input.length > 254) return false;
  return matches(RegexConstants.REGEX_EMAIL, input);
}