How do I extract domain when user inputs email?

Options

I'd like to be able to get the @domain.com part out of the user email when signing up for my application. Any idea on how to do that?

Tagged:

Answers

  • Chris Coleman
    Chris Coleman Administrator

    ADMIN

    Options

    Hi, Patopt.

    For this, you can use a combination of filters.

    1) Create a new variable, and use the email address as the value. Apply the "index" filter, with a value of @. This will return the character position of the @ in the email address--so, if my email is test@test.com, this would return 4, because the index starts at 0.

    2) In whatever step you need the domain (or you can create a new variable for this as well) use the "substr" filter to extract the domain. Your value will be the email address. The "start" parameter will be the value from the first step, with 1 added (so it trims the @ symbol).