The best place to *find* answers to programming/development questions, imo, however it's the *worst* place to *ask* questions (if your first question/comment doesn't get any up-rating/response, then u can't ask anymore questions--ridiculously unrealistic), but again, a great reference for *finding* answers.

My Music (Nickleus)


java Pattern.compile regex with "greedy quantifier" "at least n but not more than m times" curley brackets {}

X{n,m} == "greedy quantifier"
X, at least n but not more than m times
full implementation of email regex validation:
practical implementation:

so here's what i came up with:
if (!Pattern.compile("[A-Za-z0-9\\._\\-]+\\@[A-Za-z0-9\\-]+(\\.[A-Za-z0-9\\-]+)*(\\.[A-Za-z]{2,})").matcher(mail).find()){
throw new ValidatorException(new FacesMessage("Invalid email."));
i ended up choosing "X, at least n but not more than m times".
here are examples of valid emails checked against my regexp above:

No comments:

Post a Comment