Java examples for Regular Expressions:Email
Get string with @ in between using regex for email
import java.util.Scanner; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static void main(String[] args) { String input = "asdf@asdf.bet"; //proccesing ... Pattern pattern = Pattern.compile("([a-zA-Z.-_]+)@([a-zA-Z-]+\\.[a-zA-Z]+)"); Matcher matcher = pattern.matcher(input); while (matcher.find()) { System.out.println(matcher.group(1) + "@" + matcher.group(2)); // split & print user@host }/*from w ww .j a va 2s .c o m*/ } }