{"id":592,"date":"2017-07-19T14:15:59","date_gmt":"2017-07-19T08:45:59","guid":{"rendered":"http:\/\/www.cyberaka.com\/?p=592"},"modified":"2017-07-19T14:15:59","modified_gmt":"2017-07-19T08:45:59","slug":"java-code-to-extract-email-from-text","status":"publish","type":"post","link":"https:\/\/www.cyberaka.com\/?p=592","title":{"rendered":"Java Code To Extract Email From Text"},"content":{"rendered":"<p>I found a <a href=\"http:\/\/www.firatatagun.com\/blog\/2009\/12\/28\/java-email-extractor-extract-email-address-from-string-text-file\/\">good piece of code<\/a> which can be used to extract multiple email from a String. A modified version of the code is listed below:<\/p>\n<pre>public static String readContactEmailFromString(String resumeText) {\r\n    final String RE_MAIL = \"([\\\\w\\\\-]([\\\\.\\\\w])+[\\\\w]+@([\\\\w\\\\-]+\\\\.)+[A-Za-z]{2,4})\";\r\n    Pattern p = Pattern.compile(RE_MAIL);\r\n    Matcher m = p.matcher(resumeText);\r\n\r\n    StringBuilder sb = new StringBuilder();\r\n    while(m.find()) {\r\n        if (sb.toString().contains(m.group(1))) continue;\r\n        if (sb.toString().isEmpty()) {\r\n            sb.append(m.group(1));\r\n        } else {\r\n            sb.append(\"; \" + m.group(1));\r\n        }\r\n    }\r\n    return sb.toString();\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I found a good piece of code which can be used to extract multiple email from a String. A modified version of the code is listed below: public static String readContactEmailFromString(String resumeText) { final String RE_MAIL = &#8220;([\\\\w\\\\-]([\\\\.\\\\w])+[\\\\w]+@([\\\\w\\\\-]+\\\\.)+[A-Za-z]{2,4})&#8221;; Pattern p = Pattern.compile(RE_MAIL); Matcher m = p.matcher(resumeText); StringBuilder sb = new StringBuilder(); while(m.find()) { if (sb.toString().contains(m.group(1))) [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[],"class_list":["post-592","post","type-post","status-publish","format-standard","hentry","category-java"],"_links":{"self":[{"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=\/wp\/v2\/posts\/592","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=592"}],"version-history":[{"count":1,"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=\/wp\/v2\/posts\/592\/revisions"}],"predecessor-version":[{"id":593,"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=\/wp\/v2\/posts\/592\/revisions\/593"}],"wp:attachment":[{"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=592"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=592"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=592"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}