You can use a regular expression.
A pattern that matches your input is: ^it\w*@uom.edu.gr
. the \w*
means
Zero or more of any word character (letter, number, underscore)
If you want to include more symbols e.g. "." but to exclude the "@" for obvious reasons you can change the pattern to use [^@]*
which means
Zero or more of any single character excluding the "@".
So the pattern becomes: ^it[^@]*@uom.edu.gr
Use any of the two suits your needs.
Example code:
Pattern p = Pattern.compile("^it\\w*@uom.edu.gr");
Matcher m = p.matcher("itxxxxxx@uom.edu.gr");
boolean b = m.matches();
The above can be expanded as per you have been requested, e.g.:
public static void main(String[] args)throws Exception{
String email = "itxxxxxx@uom.edu.gr";
Pattern p = Pattern.compile("^it\\w*@uom.edu.gr");
Matcher m = p.matcher(email);
boolean b = m.matches();
if(b) {
System.out.println("Valid email");
} else {
System.out.println("Invalid email.");
}
}