KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > crazybob > util > EmailUtils


1 // =====================================================
2
// Author: Marc Logemann - [marc@logemann.info]
3
// originally created: 09.06.2003 - 18:46:08
4
// Class: org.crazybob.util.EmailUtils
5
// =====================================================
6
package org.crazybob.util;
7
8 import java.util.regex.Pattern JavaDoc;
9 import java.util.regex.Matcher JavaDoc;
10
11 public class EmailUtils {
12
13    /**
14     * Format the friendlyFrom in a way that the email client can display it, so no
15     * crazy characters like "@", ":", "_" or others
16     * @param friendlyFrom
17     * @return formatted friendlyFrom
18     */

19    public static String JavaDoc formatFriendlyFrom(String JavaDoc friendlyFrom) {
20       Pattern JavaDoc p = Pattern.compile("[@:_\\/\',]");
21       Matcher JavaDoc m = p.matcher(friendlyFrom);
22       String JavaDoc s = m.replaceAll("");
23       return s;
24    }
25 }
26
Popular Tags