I am trying to get emails from a String which is like:
"*** [email protected]&&^ [email protected]((& ";
private static Pattern p = Pattern.compile("(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9-.]+$)");
The code above can get one email.
How can I get all?
try
String s = "*** [email protected]&&^ [email protected]((& ";
Matcher m = Pattern.compile("[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9-.]+").matcher(s);
while (m.find()) {
System.out.println(m.group());
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With