REGEXVAULTv2.0
Identity & PII/Health Identifiers
Verified Safe

EU European Health Insurance Card (EHIC) Number Regex for PHP

/^[A-Z0-9]{8,20}$/

What this pattern does

This page provides a lightweight, single-purpose regular expression for matching eu european health insurance card (ehic) number, ported and verified for PHP. Identity and credential patterns need both correctness and safety, since they're frequent targets for adversarial input. The snippet below is ready to drop into your PHP project — whether you're validating in a Laravel validator, a WordPress plugin, or a standalone PHP script.

Php Implementation

Php
<?php
// EU European Health Insurance Card (EHIC) Number
// ReDoS-safe | RegexVault — Identity & PII > Health Identifiers

define('EU_EUROPEAN_HEALTH_INSURANCE_CARD_EHIC_NUMBER_PATTERN', '/^[A-Z0-9]{8,20}$/');

function validate_eu_european_health_insurance_card_ehic_number(string $input): bool {
    return (bool) preg_match(EU_EUROPEAN_HEALTH_INSURANCE_CARD_EHIC_NUMBER_PATTERN, $input);
}

// Example
var_dump(validate_eu_european_health_insurance_card_ehic_number("12345678")); // bool(true)

Test Cases

Matches (Valid)
Rejects (Invalid)
123456781234567
ABCD1234EFGH5678ABCD1234 EFGH
123456789012345678AB CD12

When to use this pattern

This pattern is drawn from the Identity & PII > Health Identifiers category and carries a ReDoS-safe certification. That matters for PHP developers because especially relevant in PHP where PCRE backtracking limits can trigger silent failures on malicious input. RegexVault audits patterns against known backtracking attack vectors, ensuring you have the necessary context before using this regex in a high-stakes production environment.

Common Pitfalls

EHIC is not a payment card — it proves entitlement to healthcare when temporarily in another EU/EEA country. It contains no payment details.

Technical Notes

EHIC personal identification numbers vary significantly by issuing country. The card itself contains: country code, personal identification number, card number, and expiry date. Use country-specific patterns when the issuing country is known. UK issued the Global Health Insurance Card (GHIC) post-Brexit.

Have a pattern that belongs in the vault?

Submit it for review — community-verified patterns get credited to your GitHub handle. Free submissions join the queue. Priority review available for $15.

Submit a Pattern