This tutorial shows you on how to extract the domain name from an email address by using PHP, Java, VB .NET, C# and Python programming language. The below sample code is useful when you need to extract the domain name to be supplied into FraudLabs Pro REST API (for email_domain field). You may visit the screen order API page to learn more.
Extract Domain in PHP
<?php $email = 'user@example.com'; $domain = substr($email, strpos($email, '@') + 1); ?>
Extract Domain in Java
String email = "user@example.com"; String domain = email .substring(email .indexOf("@") + 1);
Extract Domain in VB.NET
Dim email As String = "user@example.com" Dim startIndex As Integer = email.IndexOf("@") Dim endIndex As Integer = email.IndexOf(".", startIndex) Dim domain As String = email.SubString(startIndex + 1, endIndex)
Extract Domain in C#
string email = "user@example.com"; int indexOfAt = email.IndexOf('@'); string domain = email.Substring(indexOfAt + 1);
Extract Domain in Python
email = 'user@example.com' domain = email.split('@')[1]
Ready to start with FraudLabs Pro?
Get Micro plan for free, you can quickly explore and integrate with our fraud prevention solution in minutes.