I'm trying to create a Regex expression in Java for an email address and I'm stuck. When I use some of the online Regex testers it works fine but in Java it doesn't seem to want to work.
Here's my expression:
[a-zA-Z!$.&\\d]{4,24}[@][a-zA-Z]{2,}[.edu|.com|.net]
It is supposed to be:
- a 4-24 character username that can have digits, ".", "&", "$", and "!" in it
- "@" character following
- at least 2 characters for the domain but can include stuff like "school.alt"
- and the ending can only be ".net", ".com", or ".edu".
Can't figure out what I'm doing wrong.
Even if I test it against a simple email like "test@school.edu" it doesn't match.