Results 1 to 2 of 2

Thread: Email Breakdown

  1. #1
    Join Date
    Aug 2002
    Posts
    2

    Unanswered: Email Breakdown

    I need to isolate the domain name of email addresses. ie I want to access the 'Hotmail' in an email address like John@Hotmail.com. I'm sure I'm not the first one to do this and would like an idea how this could be done in DB2. I want to extract the full domain name starting after the @sign and excluding the .com, .org .whatever at the end. I know thet occasionally there will be embedded periods in the domain name. Thanks for any ideas you may have.

  2. #2
    Join Date
    Jun 2002
    Location
    UK
    Posts
    525
    You can strip out the domain (including the .com) as below...

    values (
    substr('John@Hotmail.com'
    ,locate('@','John@Hotmail.com') + 1
    ,length('John@Hotmail.com') - locate('@','John@Hotmail.com'))
    );

    You could modify this easily enough to take the substring from the position after the first @ to the position before the first period, but as you say, you might have a period in the domain name (or more likely the recipients name), so this wouldn't always work.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •