find emails in a String

This question already has an answer here:

  • How to validate an email address using a regular expression? 74 answers

  • 尝试

        String s = "*** test@gmail.com&&^ test2@gmail.com((& ";
        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());
        }
    

    只要删除^$锚。

    链接地址: http://www.djcxy.com/p/16564.html

    上一篇: 使用正则表达式进行简单电子邮件验证

    下一篇: 在字符串中查找电子邮件