REGEXVAULTv2.0
Identity & PII/Biometric & Physical
Verified Safe

Height (Metric and Imperial) Regex for PHP

/^(?:(1[0-9]{2}|2[0-5][0-9])\s?cm)|(?:([1-8])'(?:\s?(?:0|[1-9]|1[01])"?)??)$/i

What this pattern does

This page provides a comprehensive, battle-tested regular expression for matching height (metric and imperial), 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
// Height (Metric and Imperial)
// ReDoS-safe | RegexVault — Identity & PII > Biometric & Physical

define('HEIGHT_METRIC_AND_IMPERIAL_PATTERN', '/^(?:(1[0-9]{2}|2[0-5][0-9])\s?cm)|(?:([1-8])\'(?:\s?(?:0|[1-9]|1[01])"?)??)$/');

function validate_height_metric_and_imperial(string $input): bool {
    return (bool) preg_match(HEIGHT_METRIC_AND_IMPERIAL_PATTERN, $input);
}

// Example
var_dump(validate_height_metric_and_imperial("175cm")); // bool(true)

Test Cases

Matches (Valid)
Rejects (Invalid)
175cm99cm
175 cm260cm
6'2"9'
5'10"5'13"
5'5ft 10in
200cmcm175
183 CM

When to use this pattern

This pattern is drawn from the Identity & PII > Biometric & Physical 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

Height alone is rarely identifying. Combined with name, DOB, and other attributes, it becomes part of a biometric profile. The GDPR biometric data category applies when height is processed to uniquely identify a person.

Technical Notes

Metric range: 100-259 cm (practical human height range). Imperial: 1-8 feet, 0-11 inches. Height is body measurement data — classified as sensitive personal data in some jurisdictions (biometric data under GDPR if combined with other identifiers).

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