I have here a pattern for email
Pattern pattern = Pattern.compile("^[A-Za-z0-9+_.-]+@(.+)$");
also i have a String contains messages
String message = "Han hannibal@domain.com im 20 years old, i just came here to say nothing..";
my problem is when matching pattern to string i get nothing. here what i do
Pattern pattern = Pattern.compile(pattern);
Matcher m = pattern.matcher(message);
if(m.find()) {
Log.d("TAG", m.group(1));
}else {
Log.d("TAG", "No email found on string");
}
i don't if my code was right but i just simply follow some article on fetching words on string using regex.