Blog / Tutorial

Email Regex C# Guide: Simplified Validation with Practical Examples

Fuego Team /

When dealing with email validation in your C# applications, a common approach is to use regular expressions (regex). While regex is powerful, it should not be overly complex nor too strict, as it can result in rejecting valid email addresses. This guide provides a ‘good enough’ regex for basic email format validation, practical examples, and a complementary approach using a lead enrichment API to learn who’s actually behind an address.

Basic Email Regex in C#

Here’s a practical regex pattern you can use to validate email addresses in C#:

using System;
using System.Text.RegularExpressions;

class Program
{
    static void Main()
    {
        string emailRegex = @"^[^@\s]+@[^@\s]+\.[^@\s]+$";
        Regex regex = new Regex(emailRegex);

        string[] testEmails = {
            "[email protected]",
            "[email protected]",
            "invalidemail@domain",
            "@novalue.com",
            "[email protected]",
            "[email protected]",
            "[email protected]"};

        foreach (string email in testEmails)
        {
            Console.WriteLine($"{email} is {(regex.IsMatch(email) ? "valid" : "invalid")}");
        }
    }
}

Expected Output

[email protected] is valid
[email protected] is valid
invalidemail@domain is invalid
@novalue.com is invalid
[email protected] is valid
[email protected] is valid
[email protected] is valid

Explanation of the Regex Pattern

  • ^[^@\s]+: Ensures the string starts with one or more characters that are not ‘@’ or whitespace.
  • @: Requires an ‘@’ symbol.
  • [^@\s]+: Ensures the domain name contains one or more characters that are not ‘@’ or whitespace.
  • \.: Requires a literal dot ‘.’.
  • [^@\s]+$: Ensures the domain extension contains one or more characters that are not ‘@’ or whitespace and the string ends there.

Examples of Valid Email Addresses

Examples of Invalid Email Addresses

  • invalidemail@domain (no dot in the domain)
  • @novalue.com (nothing before the ‘@’)

What This Regex Lets Through

A simple pattern only checks the overall shape of an address, so a few addresses that no real mailbox could have still pass:

That’s an acceptable trade-off for a quick format check. These addresses are rare, and none of them have a real domain behind them, so a DNS lookup on the domain will catch them.

Justification for the Regex Complexity

This ‘good enough’ regex is simple and covers most common email formats without over-complicating the validation logic. While stricter regex patterns can catch more edge cases, they may also reject valid emails. For example, a rule that only allows two- to four-letter extensions would reject addresses on newer domains like .agency or .photography.

Beyond Regex: Know Who Just Signed Up

A regex only checks format. It can’t tell you whether an address is a disposable throwaway, whether its domain has DNS MX records, or whether the person signing up works at an enterprise your sales team should hear about. Fuego’s lead enrichment API answers those questions with one call, fast enough to run inside your signup flow:

  • Segment: the organization behind the address and its category (enterprise, smb, education, government, nonprofit or individual), plus its name, industry, employee count and country
  • Block abuse: disposable, role and free flags, a DNS-only has_mx check, and a simple risk level
  • Fix typos: a did_you_mean suggestion for mistakes like gmail.cmo
using System;
using System.Net.Http;

// Enrich an email with Fuego
string token = Environment.GetEnvironmentVariable("FUEGO_KEY");
string email = "[email protected]";
string url = $"https://app.gofuego.io/api/v1/enrich?email={Uri.EscapeDataString(email)}&token={Uri.EscapeDataString(token)}";

using HttpClient client = new HttpClient();
string response = await client.GetStringAsync(url);

// JSON with category, risk, disposable, organization and more
Console.WriteLine(response);

That’s enough to route enterprise signups to sales, block throwaway accounts, and tailor onboarding without asking new users a single survey question.


By combining regex and a lead enrichment API, you’ll cover a wide range of needs, from basic syntax checks to knowing exactly who just signed up. Start a free trial to try it out.

Segment your next signup in under 200ms

Start a free trial today. No survey, no scraped data, no lost signups.