i'm really really bad with regexes. can anyone help me build a java regex that accept only email finishing with .ca.
i've tried something like
^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*
@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.ca$;
Thanks
i'm really really bad with regexes. can anyone help me build a java regex that accept only email finishing with .ca.
i've tried something like
^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*
@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.ca$;
Thanks
in the spirit of teaching you how to fish... these are all directly relevant to problems with your attempt and might help you improve.
. to make it literal by using \\.. By double-escaping it you are saying that you want a literal slash followed by a single character wildcard. So that should be \. I see you doing this for other special characters too. [.]. that means literal dot as well and doesn't use any escaping. \\+[A-Za-z] simpler as [A-z] [0-9] could be written as [\d][_A-z0-9] coudl be written as [\w])To get you going immediately this should work:
([\w-\.]+)@((?:[\w]+\.)+)(ca)