ExtractEmail { @UserFunction("apoc.data.email") @Description("apoc.data.email('email_address') as {personal,user,domain} - extract the personal name, user and domain as a map") public Map<String,String> email(final @Name("email_address") String value) { if (value == null || value.indexOf('@') == -1) { return null; } try { InternetAddress addr = new InternetAddress(value); String rawAddr = addr.getAddress(); int idx = rawAddr.indexOf('@'); return (Map)Util.map("personal",addr.getPersonal(), "user", rawAddr.substring(0, idx), "domain",rawAddr.substring(idx+1)); } catch(AddressException adr) { return null; } }  @UserFunction("apoc.data.email") @Description("apoc.data.email('email_address') as {personal,user,domain} - extract the personal name, user and domain as a map") Map<String,String> email(final @Name("email_address") String value);  }
@Test public void testEmail() { testCall(db, "RETURN apoc.data.email('foo@bar.baz').domain AS value", row -> Assert.assertThat(row.get("value"), equalTo("bar.baz"))); }