Custom field normalization
<p>I have created a custom field of type Text Area in my Sandbox environment and would like to know how to normalize the text typed into this custom field.</p>

<p>In order to make a normalization I've implememted the following method:</p>

<pre><code>public String domainNormalization(Account accountObj) {
    String domain = accountObj.Domain__c;
    if (domain != null) {
        domain = domain.replaceAll('[ ]+', '');
        domain = domain.replaceAll('[,;:*]+', ' ');
        domain = domain.replaceAll('(https?://www.|https?|www.)', ' ');
        domain = domain.replaceAll('(A-Za-z\\d._~:/?#\\[\\]@!$&amp;\'()*+,;=-)', ' ');
        accountObj.Domain__c = domain;
        return domain;
    }
    return '';
}
</code></pre>

<p>But when I am able to add in the domain field: 
<a href="http://i.stack.imgur.com/laKcr.png" rel="nofollow">Screenshot 1</a></p>

<p>The code in the normalization method does not work because I get the following:
<a href="http://i.stack.imgur.com/67cwJ.png" rel="nofollow">Screenshot 2</a></p>

<p>It should always look for string(domainname) + dot "." + the extension of the domain(com, eu, bg and etc). Where the separator between these must be a single space for example: domain.com secondomain.com thirddomain.com</p>

<p>Coud you please advise how to normalize the text typed in the domain field in order to achive the same result in the given example?</p>

<p>I also would like to know is there a way to get all possible domain extensions(com, eu, bg and etc)? Do I need special consideration about domains such as for instance (co.uk)?</p>

<p>Regards,</p>

<p>Dilyan  </p>