AnsweredAssumed Answered

email script token not working

Question asked by 26c17b688a95c1b941e623e4bb6cc60338018d60 on Oct 11, 2016
Latest reply on Oct 13, 2016 by sanford.whiteman

Hi friends,

 

I'm writing a script token that removes the domain extension (like ".com" or ."org") of an email address before displaying the result whenever called from a flow.

It's not working. Perhaps I've done something wrong here. Please can anyone help?

 

set ($leadEmail=${lead.Email})   

set ($fiveLetterEnding = [".co.uk", ".co.jp", ".co.za"])

set ($fourLetterEnding = [".info", ".name", ".mobi"])

set ($threeLetterEnding = [".com", ".net", ".edu", ".gov", ".org", ".biz"])

set ($twoLetterEnding = [".fr", ".be"])

 

If ($leadEmail.matches("^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,6}$"))

  foreach ($fiveLetterEnding)

    if ($leadEmail.matches("^$fiveLetterEnding"))

    $leadEmail=$leadEmail.substring(0, 4)

    end

  end

  foreach ($fourLetterEnding)

    if ($leadEmail.matches("^$fourLetterEnding"))

    $leadEmail=$leadEmail.substring(0, 3)

    end

  end

  foreach($threeLetterEnding)

    if ($leadEmail.matches("^$threeLetterEnding"))

    $leadEmail=$leadEmail.substring(0, 2)

    end

  end

  foreach($twoLetterEnding)

    if ($leadEmail.matches("^$twoLetterEnding"))

    $leadEmail=$leadEmail.substring(0, 1)

    end

  end

 

end

Outcomes