~/devtools / regex / email
tool::regex-guide

regex email

/^[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}$/i

メールアドレス検証

ad · 728×90
正規表現パターン
/^[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}$/i
フラグ:i
パターン解析
^Start of string
[a-zA-Z0-9._%+\-]+Local part: letters, digits, dots, special chars
@Literal @ symbol (required)
[a-zA-Z0-9.\-]+Domain name: letters, digits, dots, hyphens
\.Literal dot before TLD
[a-zA-Z]{2,}TLD: at least 2 letters (com, org, io…)
$End of string
マッチ例
user@example.com
name.surname+tag@sub.domain.org
dev@company.io
非マッチ例
user@
@domain.com
no-at-sign.com
user @example.com

RFC 5322に基づいた実用的なメールアドレス検証パターンです。@記号の前のローカル部と後のドメイン部に分かれ、最も一般的なメール形式をカバーします。国際化ドメイン(IDN)やIPアドレス形式のドメインには別途処理が必要です。

言語別の使用方法

JavaScriptRegExpオブジェクトまたはリテラル構文を使用
const pattern = /^[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}$/i;

// Test a string
console.log(pattern.test("user@example.com")); // true
console.log(pattern.test("user@")); // false

// Match and extract
const result = "user@example.com".match(pattern);
Pythonreモジュールを使用
import re

pattern = r"^[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}$"
flags = re.IGNORECASE

# Test a string
if re.fullmatch(pattern, "user@example.com", flags):
    print("Valid")

# Find all matches in text
matches = re.findall(pattern, text, flags)
Javajava.util.regexパッケージを使用
import java.util.regex.*;

String pattern = "^[a-zA-Z0-9._%+\\-]+@[a-zA-Z0-9.\\-]+\\.[a-zA-Z]{2,}$";
Pattern p = Pattern.compile(pattern, Pattern.CASE_INSENSITIVE);

Matcher m = p.matcher("user@example.com");
boolean isValid = m.matches(); // true

// Find occurrences
Matcher finder = p.matcher(inputText);
while (finder.find()) {
    System.out.println(finder.group());
}

主なユースケース

  • 会員登録フォームのメール入力検証
  • ニュースレター購読のメール検証
  • データベースのメールカラム形式確認
  • CSVファイルのメールデータクリーニング
  • APIリクエストボディのメールフィールド検証

関連パターン

phone/^\+?[\d\s\-\(\)]{7,15}$/url/^https?:\/\/[^\s\/$.?#].[^\s]*$/iip-address/^((25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\./date/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[/
ad · 300×250
Regexテスターに戻る
// related tools
Cron Expression Generator
ビジュアルエディタでcron式を作成・解析。次回5回の実行時刻をプレビューし、よく使うプリセットから始められます。
jwt
JWT Decoder
JWTトークンをデコードして内容を確認。ヘッダー・ペイロード・署名の詳細を表示します。
Color Converter
HEX・RGB・HSL形式でカラーコードを変換。カラーピッカーで視覚的に選択できます。
ts
Timestamp Converter
Unixタイムスタンプを人間が読める日付に変換。ms/s・UTC/ローカル・相対時刻に対応。